开发者

WindowStatupLocation = CenterScreen is not working correctly in WPF

开发者 https://www.devze.com 2023-01-01 13:55 出处:网络
In the properties for the parent window I set WindowStatupLocation=CenterScreen In the properties for the Child window I set WindowStatupLocation=CenterOwner

In the properties for the parent window I set WindowStatupLocation=CenterScreen In the properties for the Child window I set WindowStatupLocation=CenterOwner

on the button click in the parent window if i show child window, the child window position is not center owner.

Is this is a bug in WPF or I am doing somethi开发者_如何学运维ng wrong?


You have to set the owner of the child window to the parent window.

WindowChild windowChild = new WindowChild();
windowChild.WindowStartupLocation = WindowStartupLocation.CenterOwner; // you can set this in xaml
windowChild.Owner = this; // this is parent window
windowChild.Show();


Have you tried to explicitly set the ChildWindow.Parent property with the window that will be its parent ?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号