WPF WindowStartupLocation=“CenterOwner” not really center, and pops all over, why?

后端 未结 5 584
陌清茗
陌清茗 2020-12-29 00:54

Well this question and this question are similar but no answers that work. In fact I was hoping WindowStartupLocation=CenterOwner would work...it doesn\'t. It seems to cent

5条回答
  •  执念已碎
    2020-12-29 01:30

    If you create an extention for this, you could reuse this fine idea:

    /// 
    /// Opens a window modally, with an owner
    /// 
    /// The window to open
    /// The owner of the window getting opened
    /// window.ShowDialog()
    public static bool? ShowDialog(this Window window, Window opener)
    {
        window.Owner = opener;
        return window.ShowDialog();
    }
    

提交回复
热议问题