开发者

WindowStatupLocation = CenterScreen is not working correctly in WPF

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜