Winform嵌套的WPF UserControl边框未显示

时间:2009-11-23 00:26:02

标签: c# wpf winforms user-controls border

我有一个WPF UserControl嵌套在WinForm UserControl中的ElementHost中,旨在用于Excel自定义任务窗格(CTP)。 WinForms没有在我的WPF UserControl上显示边框。这是为什么?

WPF UserControl:

<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 Designer中也显示错误。

1 个答案:

答案 0 :(得分:1)

啊,现在我看到代码我可以看到问题是因为你没有Border元素上的BorderThickness属性。添加BorderThickness =“1”。

相关问题