我有代码动态添加一些按钮,这些按钮有 mousedown 事件。当我单击按钮时,调用 mousedown 函数。我想确定我在此事件函数中单击的按钮。Button.Name 属性是有限的字符串值。
正是我想要更低的代码。
...
Button btnTest = new Button();
btnTest.identificationvalue="111.";
btnTest.MouseDown+=new MouseButtonEventHandler(deletec);
...
private void deletec(object sender, RoutedEventArgs e)
{
string idvalue=((Button)sender).identificationvalue;
if ( idvalue== "111.")
{
}
else if (idvalue == "110.")
{
}
...
}
...