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>
加载中,请稍侯......
精彩评论