Bind event handler to button with RoutedEventHandler
//File:Window.xaml.cs
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Media;
using System.Windows.Shapes;
namespace WpfApplication1 {
public partial class StackPanelDemo : Window {
public StackPanelDemo() {
InitializeComponent();
this.canvasButton.Click += new RoutedEventHandler(canvasButton_Click);
}
void canvasButton_Click(object sender, RoutedEventArgs e) {
Console.WriteLine("clicked");
}
}
}