我有许多通过代码动态创建的文本框。确定哪个文本框已触发文本更改事件
我希望能够为文本的所有文本框分配一个通用事件处理程序,然后在处理程序中确定哪个文本框已激发该事件。
代码,我是:
txtStringProperty.TextChanged += TextBoxValueChanged;
private void TextBoxValueChanged(object sender, RoutedEventArgs e)
{
string propertyName = // I would like the name attribute of the textbox here
}
请让我知道,如果你需要的信息了。
您可能不应该通过“通过代码”创建控件,而是使用[数据模板](http://msdn.microsoft.com/zh-cn/library/ms742521.aspx)。 –