我有以下场景(我已将其剥离为示例应用程序):
WindowsFormsHostform1.Show(this).问题是:
.Owner属性为null.
.Owner属性的一些工作已经完成,这意味着我不能忽略这个问题.当然,理想情况下,这里没有任何依赖性..Owner属性设置正确.我能理解为什么这里有问题,但我希望我的下一个问题的答案可能是'是'!
有什么方法可以通过在等式的WPF方面进行更改来实现这一点吗?
如果不这样做,可以在WinForms方面做任何事情吗?(这可能超出了我可以在那里实现一些变化的可能性......)
这是我的示例应用程序中的代码.首先是WPF方面:
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:my="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="700">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Button Name="btnAdd" Click="btnAdd_Click" Content="Add Winform"/>
<WindowsFormsHost Grid.Row="1" Name="host" ScrollViewer.CanContentScroll="False"/>
</Grid>
</Window>
Run Code Online (Sandbox Code Playgroud)
public partial class MainWindow : Window
{
private WindowsFormsHost host;
public MainWindow()
{
InitializeComponent(); …Run Code Online (Sandbox Code Playgroud)