wpf
wpf copied to clipboard
error when using winformhost in wpf frameless window please help
the app works normally and resize works when i dont use WindowsFormsHost but when i use it and try to resize the app the WindowsFormsHost area becomes transparent and shows the background apps, please someone help i have tryed everything
`<Window x:Class="Android_player_2.Home" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Android_player_2" xmlns:src="clr-namespace:Android_player_2.Src"
xmlns:pages="clr-namespace:Android_player_2.Src.Pages"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:winforms="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
mc:Ignorable="d"
Title="Home" Height="450" Width="800"
KeyDown="Home_OnKeyDown"
KeyUp="Home_OnKeyUp"
Loaded="Home_OnLoaded"
AllowsTransparency="False"
Background="Black"
>
<!-- <Window.Resources> -->
<!-- <Style TargetType="{x:Type Window}"> -->
<!-- <Setter Property="WindowChrome.WindowChrome"> -->
<!-- <Setter.Value> -->
<!-- <WindowChrome GlassFrameThickness="0" -->
<!-- CornerRadius="0" -->
<!-- CaptionHeight="0" -->
<!-- /> -->
<!-- </Setter.Value> -->
<!-- </Setter> -->
<!-- </Style> -->
<!-- </Window.Resources> -->
<!-- #BF000000 -->
<WindowChrome.WindowChrome>
<WindowChrome x:Name="chrome" CornerRadius="0" GlassFrameThickness="5" CaptionHeight="0" ></WindowChrome>
</WindowChrome.WindowChrome>
<!-- <WindowChrome.WindowChrome> -->
<!-- <WindowChrome CornerRadius="0" GlassFrameThickness="0" CaptionHeight="0" ></WindowChrome> -->
<!-- </WindowChrome.WindowChrome> -->
<!-- <WindowChrome.WindowChrome> -->
<!-- <WindowChrome -->
<!-- ResizeBorderThickness="6" -->
<!-- CaptionHeight="30" -->
<!-- CornerRadius="0" -->
<!-- GlassFrameThickness="0" -->
<!-- UseAeroCaptionButtons="False"/> -->
<!-- </WindowChrome.WindowChrome> -->
<Grid Margin="0" >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/> <!-- Title Bar -->
<RowDefinition Height="*"/> <!-- Content Area -->
</Grid.RowDefinitions>
<pages:TitleBar x:Name="CustomTitleBar"
Grid.Row="0"
Title="Home"
ParentWindow="{Binding RelativeSource={RelativeSource AncestorType=Window}}"></pages:TitleBar>
<!-- <src:Video_player Grid.Row="1" ></src:Video_player> -->
<!-- <src:Display_view Grid.Row="1" ></src:Display_view> -->
<!-- <src:del_test Grid.Row="1" ></src:del_test> -->
<WindowsFormsHost Grid.Row="1" x:Name="windowsFormsHost" Margin="5" Background="Black" >
<wf:Form x:Name="winFormsForm"
FormBorderStyle="None"
ShowInTaskbar="False"
BackColor="Black"
TopLevel="False"/>
</WindowsFormsHost>
</Grid>
`
Can you provide some demo project for reproducing the issue?
do you want me to create a new repo and push my project to github, but it pretty easy to recreate the issue just create a new wpf app and make it frameless using WindowChrome then use winformhost to host the winform then when you resize the winform area becomes transparent and can show the background apps and folders
It may be the Airspace issuse
then how can i fix it , and also its not letting me overlay wpf elements on top of winformhost
@mikiboii Can you provide all your code?
It may can not find any good solution.
this is my code https://github.com/mikiboii/Player_demo/tree/master/Player_demo it uses directx and ffmpeg to display frames in winformhost but it dosent let buttons or text overlay the winformhost
@mikiboii
but it dosent let buttons or text overlay the winformhost
Yes, this is the known limitation.
Related: https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/technology-regions-overview
A hosted Windows Forms control is drawn in a separate HWND, so it is always drawn on top of WPF elements.
https://learn.microsoft.com/en-us/dotnet/desktop/wpf/advanced/layout-considerations-for-the-windowsformshost-element
Note that this is a different issue than you reported though, I don't think transparency is expected here, although the player might be involved. Can you reproduce the issue with just a WindowsFormsHost without the player?
in this user control "VideoPlayerControl" just comment out " Loaded += OnLoaded;
Unloaded += OnUnloaded;" then try adding an overlay in the xaml on top of winformhost <WindowsFormsHost x:Name="windowsFormsHost"> <wf:Form x:Name="winFormsForm" FormBorderStyle="None" ShowInTaskbar="False" TopLevel="False"/> </WindowsFormsHost> then it will alway get in front of text, button anything