我想在WindowsFormsHost
上创建一个边框。怎么做?
在.cs文件中:
WindowsFormsHost Host = new WindowsFormsHost();
并在xaml中:
<WindowsFormsHost x:Name="Host"></WindowsFormsHost>
答案 0 :(得分:3)
System.Windows.Border
类是Decorator
类型,这意味着它可以有一个Child
元素。在这种情况下,您的孩子将是WindowsFormsHost
。
XAML:
<Border BorderBrush="Green" BorderThickness="1">
<WindowsFormsHost x:Name="Host"></WindowsFormsHost>
</Border>
答案 1 :(得分:1)
使用border类:
XAML:
<Border BorderThickness="1" BorderBrush="Green">
<WindowsFormsHost x:Name="Host"></WindowsFormsHost>
</Border>
CS:
var myBorder = new Border();
myBorder.BorderBrush = Brushes.Green;
myBorder.BorderThickness = new Thickness(1);
myBorder.Child = new WindowsFormsHost();