Reputation: 9867
I have access to User Control A. I want to get info on User Control C. Is there any way to do this in WPF? The structure is basically what you see. User Control D is a ribbon, C is a tab on the ribbon and B and A are contents of C. I can't seem to get access to C. I tried using the Parent property of A but it doesn't seem to give me the info on C.
Upvotes: 22
Views: 26940
Reputation: 445
use the Window.GetWindow(this) method within Loaded event handler.
public MainView()
{
InitializeComponent();
this.Loaded += new RoutedEventHandler(MainView_Loaded);
}
void MainView_Loaded(object sender, RoutedEventArgs e)
{
Window parentWindow = Window.GetWindow(this);
...
}
Upvotes: -1
Reputation: 89
Maybe you can try to cast the parent as UserControl C, like this:
(this.Parent as UserControlC).YourProperty
Upvotes: 4