2009-11-23 78 views
1

我有一個WPF UserControl嵌套在WinForm UserControl中的一個ElementHost內,用於在Excel自定義任務窗格(CTP)中使用。 WinForms不會在我的WPF UserControl上顯示邊框。爲什麼是這樣?Winform嵌套WPF UserControl邊框沒有顯示

WPF用戶控件:

<UserControl x:Class="InventoryCreator.MyWPFControl" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
xmlns:dg="http://schemas.microsoft.com/wpf/2008/toolkit" 
Height="547" Width="200" 
SnapsToDevicePixels="True"> 
<Grid> 
    <Button Height="38.75" Margin="12,12,13.75,0" Name="btnCreateNew" VerticalAlignment="Top" Click="button1_Click">Create New Template</Button> 
    <!-- BorderBrush not showing up inside the winform UserControl 
    but is there because the background does change --> 
    <Border BorderBrush="Azure" Background="AliceBlue" Margin="1,57,1,1"> 
     <Grid Width="178" Height="454"> 
      <dg:DataGrid Margin="3,31,7,63" /> 
      <Label Height="28" Margin="39,6,17,0" Name="availableLabel" VerticalAlignment="Top">Available Templates</Label> 
     </Grid> 
    </Border> 
</Grid> 

我裏面使用這個WinForm控件在Excel中的一個CTP,但我不知道是什麼,可能有什麼關係,因爲它是錯誤的顯示出來在WinForm設計器中也是如此。

回答

1

啊,現在我看到了代碼,我可以看到問題是因爲Border元素上沒有BorderThickness屬性。添加BorderThickness =「1」。

+0

它出現在WPF設計器中。調皮。謝謝。 – 2009-11-23 05:00:38