Hello,
Use delegate in your User Control
For example you got a button named "Add" on your control:
public partial class Test : UserControl
{
public Test()
{
InitializeComponent();
}
public delegate void RunMethodHandler(object sender);
public event RunMethodHandler RunMethod;
private void Add_Click(object sender, RoutedEventArgs e)
{
if (RunMethod != null)
RunMethod(null);
}
}
Then in your MainWindow, Add the UserControl to MainWindow. I did and renamed it to "MyControl", then:
public MainWindow()
{
InitializeComponent();
MyControl.RunMethod +=new Test.RunMethodHandler(TestMethod);
}
public void TestMethod(object sender)
{
MessageBox.Show("Ok");
}
At last, when you Click on Add, the TestMethod() will run.
Good luck.