How stupid for me to answer my question. I understood this as follows: I could add an event handler inside the class itself for all instances. Duh !! Here is the code:
public class Tool_Button:Button{
public String tool_name;
public Tool_Button(String toolname) {
this.Width = 32;
this.Height = 32;
this.BorderBrush = Brushes.Gray;
tool_name = toolname;
this.Background = new ImageBrush(new BitmapImage(new Uri(tool_name)));
this.Click += new RoutedEventHandler(Tool_Button_Click);
}
void Tool_Button_Click(object sender, RoutedEventArgs e)
{
MessageBox.Show(tool_name);
}
}
source
share