I have a user control that I load into a MainWindow at runtime. I cannot get a handle on the containing window from the UserControl.
MainWindow
UserControl
I hav
It's working for me:
DependencyObject GetTopLevelControl(DependencyObject control) { DependencyObject tmp = control; DependencyObject parent = null; while((tmp = VisualTreeHelper.GetParent(tmp)) != null) { parent = tmp; } return parent; }