Access parent window from User Control

前端 未结 6 1173
感动是毒
感动是毒 2020-12-30 19:55

I am trying to access parent window from user control.

userControl1 uc1 = new userControl1();

mainGrid.Children.Add(uc1);

through this co

6条回答
  •  没有蜡笔的小新
    2020-12-30 20:49

    This gets the root level window:

    Window parentWindow = Application.Current.MainWindow
    

    or the immediate parent window

    Window parentWindow = Window.GetWindow(this);
    

提交回复
热议问题