WPF sets parent (Window)

How to set the parent element of a WPF window if you want to show it as a dialog? Both the Show () and ShowDialog () methods do not seem to have this option.

This was possible in Java, as you could pass the parent element in the constructor. Is this possible in WPF?

EDIT: I am using C #

+5
source share
2 answers
Owner

can be set, but the parent is readonly property.

var w = new Window(); w.Owner = Window.GetWindow(this); w.Show(); 
+7
source

on your Showdialog object do:

 templateWindow.Owner= System.Windows.Application.Current.MainWindow; templateWindow.ShowDialog(); 
0
source

Source: https://habr.com/ru/post/1208962/


All Articles