In Blend, I took a simple button –> Edit Template –> Create Empty…
Added an image for the button, and filled some visual states.
Now I want to expose an OnClick event :
public partial class MyButton : UserControl
{
public MyButton()
{
// Required to initialize variables
InitializeComponent();
button.Click += Click;
}
public event RoutedEventHandler Click;
}
But this doesn’t work for me. What is wrong ?
It’s not clear what exactly doesn’t work here, but looks like you’re trying to assign
Clickdelegate to yourbutton.Clickevent whileClickis empty. What you should do is assign another delegate which will invokeClick.Replace
button.Click += Click;with: