How to change the styling of the dotted line around focused button globally in wpf?

前端 未结 1 730
难免孤独
难免孤独 2021-01-24 03:30

I have multiple buttons and images in my WPF applications and would like to make the dotted line around focused buttons and focused images thicker for all of them.

I don

相关标签:
1条回答
  • 2021-01-24 04:37

    You can simply define an implicit Style targeting Button or Image or any other focusable Controls, place this Style is such as App.Resources or some separate ResourceDictionary:

    <Style TargetType="Button">
       <Setter Property="FocusVisualStyle">
           <Setter.Value>
               <Style>
                  <Setter Property="Control.Template">
                     <Setter.Value>
                      <ControlTemplate>
                        <Rectangle StrokeThickness="2" Stroke="Black" StrokeDashArray="2"/>
                      </ControlTemplate>
                     </Setter.Value>
                  </Setter>
               </Style>
           </Setter.Value>
        </Setter>
    </Style>
    
    0 讨论(0)
提交回复
热议问题