I have an app where I have a main window that can contain other docked/attached windows. Right now, when my user control loads I get its parent using Window.GetWindow. This returns a reference to the main window, which is fine. However, when I undock/detach the child window that the user control is on, the parent changes.
There are a number of parent window events that the user control needs to listen for. I couldn’t find any way for the user control to be notified when the parent changes. It looks like ParentChanged/OnParentChanged do not exist for System.Windows.Controls.UserControl.
Is there any way my user control can be notified when its parent changes?
Thanks.
Maybe the Loaded and Unloaded events are what you need. They should also be called when the parent changes but I’m not sure about this.