我在创建时添加了焦点事件mytextbox
`TextBox Xi = new TextBox();
Xi.Name = "X" + i.ToString();
Xi.Width = 10;
Xi.Height = 10;
Xi.GotFocus += Xi_GotFocus;`
但我无法获得专注控制的名称
void Xi_GotFocus(object sender, RoutedEventArgs e)
{
throw new NotImplementedException();
}
有没有办法得到这些控件的名称?谢谢
答案 0 :(得分:1)
您可以使用下面提到的代码
void Xi_GotFocus(object sender, RoutedEventArgs e)
{
TextBox t = sender as TextBox;
string name = t.Name;
}