【发布时间】:2015-02-24 17:59:07
【问题描述】:
我有许多通过代码动态创建的文本框。
我希望能够为所有文本框分配一个通用事件处理程序,即使文本发生更改,然后在处理程序中确定哪个文本框触发了事件。
我的代码是:
txtStringProperty.TextChanged += TextBoxValueChanged;
private void TextBoxValueChanged(object sender, RoutedEventArgs e)
{
string propertyName = // I would like the name attribute of the textbox here
}
如果您需要更多信息,请告诉我。
【问题讨论】:
-
您可能不应该“通过代码”创建控件,而是使用data templates。
标签: c# wpf event-handling