Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the name of the parent user control WPF C#

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.

enter image description here

like image 329
Anthony Russell Avatar asked Jul 12 '13 20:07

Anthony Russell


2 Answers

Try using VisualTreeHelper.GetParent or use the recursive function here

like image 137
Rwiti Avatar answered Oct 09 '22 08:10

Rwiti


Maybe you can try to cast the parent as UserControl C, like this:

(this.Parent as UserControlC).YourProperty
like image 39
Guilherme H. J. Avatar answered Oct 09 '22 08:10

Guilherme H. J.