I have multiple textboxes with TextChanged events bound to the same handler
<TextBox TextChanged="TextBox_TextChanged" />
<TextBox TextChanged="TextBox_TextChanged" />
<TextBox TextChanged="TextBox_TextChanged" />
<TextBox TextChanged="TextBox_TextChanged" />
Is there any way to do something like this?
<StackPanel>
<StackPanel.Resources>
<Style TargetType="TextBox">
<Setter Property="TextChanged" Value="TextBox_TextChanged" />
</Style>
</StackPanel.Resources>
<TextBox />
<TextBox />
<TextBox />
<TextBox />
</StackPanel>
I know the code above is invalid, but it is something similar to what I want to achieve
If I’m not mistaken, you can put the
TextBoxBase.TextChanged="TextBox_TextChanged"attribute on the common container element of all of your text boxes, for ex: