Is there anything wrong in WPF with setting the Owner property of a window to its parent in that parent\'s constructor? There shouldn\'t be, right? So why am I getting an
You need the WPF equivalent of HandleCreated
event, which is SourceInitialized
. This should work:
public OwnerWindow()
{
InitializeComponent();
SourceInitialized += (s, a) =>
{
var owned = new OwnedWindow();
owned.Owner = this;
};
}
Note that you don't have to Show
either OwnerWindow or OwnedWindow for this to work.