I have a number of text boxes that are dynamically created via code.
I would like to be able to assign a generic event handler to all the textboxes for the text changed even and then within the handler determine which text box has fired the event.
Code I have is:
txtStringProperty.TextChanged += TextBoxValueChanged;
private void TextBoxValueChanged(object sender, RoutedEventArgs e)
{
string propertyName = // I would like the name attribute of the textbox here
}
Please let me know if you require anymore information.
The sender
parameter contains which control has fired the event. You can cast it to a TextBox and get the name property from it:
string propertyName = ((TextBox)sender).Name;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With