我有WPF应用程序,如果有多个监视器,则当主窗口移至辅助屏幕时,所有子窗口仅在主监视器中打开。 我添加了
<Window x:Class="ModalDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" ResizeMode="NoResize"
Title="{Binding DialogTitle,Mode=OneWay}"
Height="{Binding DialogHeight,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
Width="{Binding DialogWidth,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
WindowState="Normal"
WindowStyle="None"
WindowStartupLocation="CenterOwner"
attachedbehavior:CenterOnSizeChangeBehaviour.CenterOnSizeChange="true">
在子窗口xaml代码中,在打开之前,我将所有者指定为主窗口。
subWindow.Owner = Application.Current.MainWindow;
我想打开主窗口所在的子窗口。