Click here to Skip to main content
15,892,059 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi Guys,
I have a Window (Window1.xaml) with a UserControl (UC1.xaml) in it and inside that UserControl is another UserControl (UC2.xaml). I have a private void in Window1.xaml that i want to run when a button is clicked in UC2.xaml.

Is it possible to run a private void from a Parents Parent Window?
Or have a Listener in Window1.xaml that is linked to the Button in UC2.xaml?

Confused? Sorry, i am kinda new to this and i am sure i have not used the right terminology. A kick (or gentle nudge) in the right direction would be greatly appreciated.
Thanks guys,
Alex
Posted

1 solution

If it were me, I'd change the protection level (if necessary) on the internal UserControl, and then subscribe to the appropriate event from the main form.

private void Load()
{
    this.userControl.innerUserControl.Button.Click += ....
}


I know, it's not very OOP-centric to expose something that should be private, but many times, convenience is better than strict adherence to some off-the-wall paradigm. :)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900