wpf 按钮点击时会画一个点线的矩形,怎么把这个矩形去掉啊?
如题
[解决办法]
cangetfocus=false
[解决办法]
FrameworkElement..::.FocusVisualStyle 属性
http://msdn.microsoft.com/zh-cn/library/system.windows.frameworkelement.focusvisualstyle.aspx
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <Page.Resources> <Style x:Key="MyFocusVisual"> <Setter Property="Control.Template"> <Setter.Value> <ControlTemplate> <Rectangle Margin="-2" StrokeThickness="0" 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></Page>
[解决办法]
恩,用FocusVisualStyle 比较灵活。
[解决办法]