在Popup中使用WinFormElementHost

时间:2013-08-02 18:37:55

标签: c# wpf

首先,我为我的英语基础薄弱道歉 我想在弹出窗口中显示我的win form用户控件但是这没有显示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;
    }
}

感谢您的关注

祝你好运

1 个答案:

答案 0 :(得分:0)

您可以使用网格,然后将WindowsFormsHost和Canvas放在网格中(WindowsFormHost位于顶部)?