I have a WPF control that I would like to apply to a WinForms application. Therefore, I dutifully created an element node that can display the following WPF object:
<UserControl x:Class="LightBoxTest.LightBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="300" Width="300" Background="Transparent"> <Grid Name="dialogHolder" Background="Transparent" Opacity="1"> <Rectangle Name="rectangle1" Stroke="White" Fill="Black" RadiusX="10" RadiusY="10" Opacity="0.5" /> <StackPanel Name="stackPanel1" Background="Transparent" Height="300" VerticalAlignment="Top"> <Rectangle Name="spacer" Opacity="0" Stroke="Gray" Fill="White" RadiusX="10" RadiusY="10" Height="100" Width="300" /> <Grid Height="100" Name="contentHolder" Width="250"> <Rectangle Name="dialog" Stroke="Gray" Fill="White" RadiusX="10" RadiusY="10" Height="100" Width="250" /> </Grid> </StackPanel> </Grid> </UserControl>
The problem is that the controls in the WinForm form are not displayed, and WPF just erases them on the screen.
An element host is created as follows:
dialogHost = new ElementHost(); dialogHost.Child = dialog; dialogHost.BackColorTransparent = true; dialogHost.BringToFront(); dialogHost.Show();
Is there something I have to do, but Im not?
Are there any known issues with transparent WPF control over Winforms?
Any article that might help?
Note. This question is related to this question.
c # controls winforms transparency wpf
TK.
source share