我目前正在用这个打开一个新窗口:

var v = new View()
{
    Owner = this,
    WindowStartupLocation = WindowStartupLocation.CenterScreen
};
v.Show();


但是,如果用户尝试打开多个窗口,则它们只会彼此堆叠。是否有明显的我想将它们级联起来以便它们都在某种程度上可见?

最佳答案

得到它的工作:

var v = new View()
{
    Owner = this
};
var ownedWindows = OwnedWindows.Cast<Window>().Where(w => w.IsVisible).ToList();
if (!ownedWindows.Any())
{
    v.WindowStartupLocation = WindowStartupLocation.CenterScreen;
}
else
{
    v.WindowStartupLocation = WindowStartupLocation.Manual;
    v.Left = ownedWindows.Max(w => w.Left) + 20;
    v.Top = ownedWindows.Max(w => w.Top) + 20;
}
v.Show();

08-19 03:52