In keyboard navigation, when a button is selected, it has a dashed border. How to change its color?
I believe what you are looking for is the FocusVisualStyle
. If you set this to null, you can hide the dashed border. In your case, you want to change the color. What you would do would be to create a new style and apply it to the FocusVisualStyle
.
Here is an MSDN article that shows you how to do this:
http://msdn.microsoft.com/en-us/library/ms744790.aspx
The basic code they list is as follows:
<Page.Resources>
<Style x:Key="MyFocusVisual">
<Setter Property="Control.Template">
<Setter.Value>
<ControlTemplate>
<Rectangle Margin="-2" StrokeThickness="1" Stroke="Red" StrokeDashArray="1 2"/>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<StackPanel Background="Ivory" Orientation="Horizontal">
<Canvas Width="10"/>
<Button Width="100" Height="30" FocusVisualStyle="{DynamicResource MyFocusVisual}">
Focus Here</Button>
<Canvas Width="100"/>
<Button Width="100" Height="30" FocusVisualStyle="{DynamicResource MyFocusVisual}">
Focus Here</Button>
</StackPanel>
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