so I have this UserControl that's inside of another UserControl. Lets call them ParentUC and ChildUC. I need to get ParentUC from ChildUC.
I know to get the window owner would be Window.GetWindow(userControl)
, but UserControl doesn't have a method like this AFAIK.
Thanks for the help!
I came up with this solution, but post if you have a better one. Thanks!
DependencyObject ucParent = this.Parent;
while (!(ucParent is UserControl))
{
ucParent = LogicalTreeHelper.GetParent(ucParent);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With