Reputation: 2626
I have two methods that need to be called when a button is pressed.
I can do it by code in this way
this.button1.Click += new System.EventHandler(this.button_Click);
this.button1.Click += new System.EventHandler(this.button_Click_1);
but how can I do it in XAML?
Upvotes: 1
Views: 464
Reputation: 9713
Assuming your form is one of your own, meaning you can change it.
Consider using a virtual method.
public class MyForm
{
public virtual void DoSomething()
{
//Some code.
System.Diagnostics.Debug.WriteLine("Hello from MyForm");
}
}
public class MyOtherForm : MyForm
{
public override void DoSomething()
{
//Call the base DoSomething first
base.DoSomething();
//Some code to run after.
System.Diagnostics.Debug.WriteLine("Hello from MyOtherForm");
}
}
If you want to achieve this in XAML
. See here as it has already been answered.
Upvotes: 1