我正在为Windows Phone 8.1编程 当我点击一个按钮时,我调用cmdDeleteBlock_Click。
AddHandler cmdDelete(1).Click, AddressOf cmdDeleteBlock_Click
AddHandler cmdDelete(2).Click, AddressOf cmdDeleteBlock_Click
AddHandler cmdDelete(3).Click, AddressOf cmdDeleteBlock_Click
...
如何获取在cmdDeleteBlock_Click中单击的按钮(ID)的名称。
Private Sub cmdDeleteBlock_Click(sender As Object, e As RoutedEventArgs)
' Get button name (Id) of button that clicked **here**
End Sub
答案 0 :(得分:2)
您可以从事件处理程序中收到的对象中获取名称。在c#中说明一个例子
protected void btn_click(object sender, RoutedEventArgs e)
{
string Name = ((Button)sender).Name;
}
同样,您也可以获得其他属性。