WPF WindowFormsHost取消始终置顶的有效解决方案
一、WinForm WindowsFormsHost 调用
1、引用
我们需要向项目中的引用(reference)中添加两个动态库dll,一个是.NET库中的System.Windows.Forms
,另外一个是WindowsFormsIntegration
;
xmlns:host="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
2、XAML
<WindowsFormsHost x:Name="gridHost" Panel.ZIndex="0" MinHeight="400" MinWidth="700" Margin="0" Padding="0"> <WindowsFormsHost.Background> <ImageBrush ImageSource="pack://application:,,,/images/defaultfrg.png"/> </WindowsFormsHost.Background> <wf:Panel x:Name="localVideo" Height="400" Width="705"/> </WindowsFormsHost>
二、WindowsFormsHost取消始终置顶的有效解决方案
1、引用
需要引用的(dll)组件下载,Microsoft.DwayneNeed.zip
xmlns:interop="clr-namespace:Microsoft.DwayneNeed.Interop;assembly=Microsoft.DwayneNeed"
2、XAML
<interop:AirspaceDecorator AirspaceMode="Redirect" IsInputRedirectionEnabled="True" IsOutputRedirectionEnabled="True"> <WindowsFormsHost x:Name="gridHost" Panel.ZIndex="0" MinHeight="400" MinWidth="700" Margin="0" Padding="0"> <WindowsFormsHost.Background> <ImageBrush ImageSource="pack://application:,,,/images/defaultfrg.png"/> </WindowsFormsHost.Background> <wf:Panel x:Name="localVideo" Height="400" Width="705"/> </WindowsFormsHost> </interop:AirspaceDecorator>
方案二,使用Popup
Popup 作为最上层,此方法跟随Window移动难控制