Search code examples
c#wpfevent-handlingtopmost

WFA Window in front


I got a WFA with a TreeView in it and I added a MouseDoubleClick event to a treeviewItem. In code the eventhandler opens a new window.

When I try this and doubleClick the TreeViewItem it opens the window but it dosn't stay in front (It moves behind my page where the TreeView is)

I tryed adding a Topmost = true in the eventhandler but that doesn't work.

Anyone got a solution?


Solution

  • You can try with Owner property in order to set focus

    var newWindow = new NewWindow();
    newWindow.Owner = this;
    newWindow.ShowDialog();