Set an event to all controls of same type
controls, events, wpf
Solution
Yes there is a way, you can use the `EventSetter` property in the `Style` to set a `EventHandler` for all `Elements` with that style applied
Example:
<Style TargetType="{x:Type TextBlock}">
<EventSetter Event="MouseLeftButtonDown" Handler="TextBlock_LeftClick" />
</Style>
Problem
In WPF is there a way to set a particular type of event to all controls of the same type. For example, I'm trying to set the MouseLeftButtonDown event on all controls of type TextBlock. Here is what I tried to do which is obviously wrong: ``` <Style TargetType="{x:Type TextBlock}"> <Setter Property="MouseLeftButtonDown" Value="TextBlock_LeftClick"/> </Style> ``` Is there a way that this can be done?