首先,我对我的英语基础很弱感到抱歉。
我想在一个弹出窗口中展示我的WinForm用户控件,但是WinFormElementHost并没有显示出来!我该怎么办?
编辑:
这是我的代码,XAML代码用于定义弹出窗口和我的用户控件类。
<Popup Name="popupDate" PopupAnimation="Scroll" Width="310" Height="310"
PlacementTarget="{Binding ElementName=buttonDate}"
AllowsTransparency="True" Margin="8,-36,-29,-13">
<Canvas Background="Transparent">
<Canvas Background="LightBlue" Width="300" Height="300">
<Canvas.BitmapEffect>
<DropShadowBitmapEffect Softness=".3"
ShadowDepth=".5"
Color="Black"/>
</Canvas.BitmapEffect>
<WindowsFormsHost Height="200" HorizontalAlignment="Left" Margin="0,0,0,0" Name="windowsFormsHost1" VerticalAlignment="Top" Width="200"/>
</Canvas>
</Canvas>
</Popup>
public partial class SearchBaseDateAndDuration : UserControl
{
Persian_Calender.Persian_Calender pc;
public SearchBaseDateAndDuration()
{
InitializeComponent();
pc = new Persian_Calender.Persian_Calender();
windowsFormsHost1.Child = pc;
}
}
感谢您的关注
祝你好运
WindowsFormsHost
XAML标记内部必须有某种WinForms控件。在这里可以看到一个DataGridView
http://mindstick.com/Articles/e87470a2-1aac-4d2a-a645-f3d9e90ba555/?WindowsFormsHost%20control%20in%20WPF 或者这里的MaskedTextBox
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.windowsformshost.aspx。在你的情况下,它会是一个特殊的日历控件吗?还是一个完整的UserControl对话框?`WindowsFormsHost`是空的。 - Csaba Toth