I have an application in wpf where I use UserControl to fill some data.I need some actions performed in the parent window while clicking on a button in UserControl.
I tried using events and delegates but failed to call the function in parent window.
What I have tried:
in my usercontrol I have code like this
public delegate void Button_ClickedEventHandler(object sender, EventArgs e);
..........
.........
public event Button_ClickedEventHandler ButtonClicked;
................
................
public void button1_Click(object sender, RoutedEventArgs e)
{
if (this.ButtonClicked != null)
this.ButtonClicked(this,e);
}
..........................................
and in the parent window
public myWindow()
{
InitializeComponent();
myClass1.ButtonClicked += new Button_ClickedEventHandler(myClass1_ButtonClicked);
}
void myClass1_ButtonClicked(object sender, EventArgs e)
{
throw new NotImplementedException();
}