我有两个显示器。当我的应用程序运行时,父级显示在第一台监视器上。当我将父窗口移动到第二个监视器并单击一个按钮(显示用于加载的 xaml 窗口)时,此子窗口将保留在第一个监视器上。无论父窗口位于何处,有没有办法让子窗口与父窗口保持一致?
请注意:父母是winform ...孩子是xaml。
加载 xaml(儿童)
<Window x:Class="Test.Loading"
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"
WindowStyle="None"
AllowsTransparency="True"
WindowState="Maximized"
Background="Gray">
<Grid>
<Border>
<TextBlock Text="Loading ..." />
</Border>
</Grid>
</Window>
家长
private void btnShowLoading_Click(object sender, EventArgs e)
{
Loading load = new Loading();
double top = this.Top;
double left = this.Left;
load.Top = top;
load.Left = left;
load.Show();
}