Tôi có một điều khiển WPF mà tôi muốn phủ lên một ứng dụng WinForms. Vì vậy, tôi đã nghiêm túc tạo ra một Host Yếu tố có thể hiển thị các đối tượng WPF sau:C# WPF minh bạch trên các điều khiển Winform
<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>
Vấn đề là các Controls trên Form WinForm không render và WPF chỉ obliterates chúng trên màn hình.
Người dẫn chương trình phần tử được tạo ra như:
dialogHost = new ElementHost();
dialogHost.Child = dialog;
dialogHost.BackColorTransparent = true;
dialogHost.BringToFront();
dialogHost.Show();
Có cái gì tôi nên làm và Im không?
Có các vấn đề đã biết về việc hiển thị các điều khiển WPF trong suốt trên Winform không?
Bất kỳ nghệ thuật nào có thể hữu ích?
Lưu ý: Câu hỏi này có liên quan đến this question