在事件上使用Setter

abe*_*nky 2 wpf events user-interface

我正在使用Setter我的WPF-UI元素来定义布局.

例如:

<Style TargetType="{x:Type TextBox}">
    <Setter Property="Width" Value="60" />
</Style>
Run Code Online (Sandbox Code Playgroud)

我也想用它们给它们所有相同的事件处理程序,例如:

<Style TargetType="{x:Type TextBox}">
    <Setter Property="GotFocus" Value="TextBox_GotFocus" />
</Style>
Run Code Online (Sandbox Code Playgroud)

但似乎我不能仅在属性上使用事件上的Setter.

有没有办法GotFocus使用类似的东西给我的所有TextBoxes相同的事件处理程序Setter

Fyo*_*kin 5

<EventSetter>改用.

..