I have a long form with a bunch of CheckBox's and occasionally some TextBox inputs. I want an event to be raised any time any control is changed (i.e., any CheckBox state is changed or any TextBox.Text is altered). Is there a global way to do this without having to add an event handler to each and every control?
One of the advantages of WPF and its declarative nature is that events are inherited down the visual tree.
<Window x:Class="MyApplication.MainWindow"
....
TextBox.TextChanged="TextBox_TextChanged" CheckBox.Checked="CheckBox_Checked">
All TextBox
and CheckBox
controls will inherit these event handlers. The same approach can be taken in other controls such as Grid
so only the controls within the Grid are affected.
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