<Button Name="btn1" Content="1" HorizontalAlignment="Left" Margin="13,127,0,0" VerticalAlignment="Top" Click="Button_Click"/>
<Button Name="btn2" Content="2" HorizontalAlignment="Left" Margin="135,124,0,0" VerticalAlignment="Top" Click="Button_Click"/>
如何通过一次函数调用获取当前按钮的内容?
答案 0 :(得分:3)
试试这个:
private void Button_Click(object sender, RoutedEventArgs e)
{
Button obj = (Button)sender;
MessageBox.Show(obj.Content.ToString());
}