Winform控件上的c#WPF透明度
我有一个WPF控件,我想覆盖到WinForms应用程序上。因此,我尽职尽责地创建了一个元素主机,它可以显示以下WPF对象:Winform控件上的c#WPF透明度,c#,wpf,winforms,controls,transparency,C#,Wpf,Winforms,Controls,Transparency,我有一个WPF控件,我想覆盖到WinForms应用程序上。因此,我尽职尽责地创建了一个元素主机,它可以显示以下WPF对象: <UserControl x:Class="LightBoxTest.LightBox" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height=
<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>
有什么我应该做而我没有做的吗
在Winforms上显示透明WPF控件是否存在已知问题
有什么有用的文章吗
注意:这个问题与有关,您可能已经尝试过了,但是如何设置用户控件的不透明度呢?这似乎是互操作问题 我想你遇到了麻烦。好了,你不能混合使用WPF透明和ElementHost透明,因为ElementHost拥有空域 链接中有一个关于创建非矩形HWND来承载WPF内容的简短介绍,这可能会让您走得更远
也许你可以考虑将更多的WiFrm应用程序迁移到WPF?
< P>你应该阅读以下内容: 只需隐藏并显示它(不酷但有效)dialogHost = new ElementHost();
dialogHost.Child = dialog;
dialogHost.BackColorTransparent = true;
dialogHost.BringToFront();
dialogHost.Show();