I am having multiple buttons with contents 1, 2, 3, 4, 5... like this. All buttons are using same function on Click event.
I tend to deal with this problem by attaching an object to the button's tooltip property. You can then get it back like this:
void EditMe(object sender, RoutedEventArgs e)
{
Button x = sender as Button;
if (x != null)
{
int id = (x.ToolTip as TT).Id;
}
}
The TT object in this example looks like:
public class TT
{
public int Id { get; set; }
public string Text { get; set; }
public override string ToString()
{
return Text;
}
}
Which displays the tooltip text on the UI and makes the Id accessible in the click handler.