日期:2014-05-18  浏览次数:20882 次

WPF expander 控件怎么去掉焦点框。
一般的控件 FocusVisualStyle="{x:Null}" 可以去掉焦点框

但是expander 加上没有启作用,我怀疑是expander .header的焦点。

但是header没有 FocusVisualStyle这个属性。

请高手指点一下 。。。

我WFP 还是比较菜的。

------解决方案--------------------
Focusable设置为false试试
------解决方案--------------------
需要在expander 的样式里设置ToggleButton的FocusVisualStyle=="{x:Null}" 直接对expander 设置FocusVisualStyle确实不能改变折叠按钮的FocusVisualStyle
------解决方案--------------------
探讨

需要在expander 的样式里设置ToggleButton的FocusVisualStyle=="{x:Null}" 直接对expander 设置FocusVisualStyle确实不能改变折叠按钮的FocusVisualStyle

------解决方案--------------------
在Expander样式中的ToggleButton设置为Focusable="False"或者FocusVisualStyle=="{x:Null}"都行.其他就没办法了...
XML code

<Style TargetType="{x:Type Expander}">
        <Setter Property="Background" Value="Transparent"/>
        <Setter Property="Foreground" Value="{StaticResource ButtonFontColor}"/>
        <Setter Property="FontWeight" Value="Bold"/>
        <Setter Property="Padding" Value="4"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="VerticalContentAlignment" Value="Stretch"/>
        <Setter Property="BorderBrush" Value="Transparent"/>
        <Setter Property="BorderThickness" Value="1"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Expander}">
                    <Border SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="1,1,1,1" CornerRadius="3">
                        <Grid>
                            <DockPanel>
                                <ToggleButton [color=#FF0000]Focusable="False"[/color] FontFamily="{TemplateBinding FontFamily}" FontSize="{TemplateBinding FontSize}" FontStretch="{TemplateBinding FontStretch}" FontStyle="{TemplateBinding FontStyle}" FontWeight="{TemplateBinding FontWeight}" Foreground="{TemplateBinding Foreground}" HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" FocusVisualStyle="{StaticResource ExpanderHeaderFocusVisual}" Margin="1,1,1,0" MinHeight="0" MinWidth="0" x:Name="HeaderSite" Style="{StaticResource ExpanderDownHeaderStyle}" Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" ContentTemplateSelector="{TemplateBinding HeaderTemplateSelector}" IsChecked="{Binding Path=IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" DockPanel.Dock="Top"/>
                                <Border x:Name="border" Grid.Column="0" Grid.Row="1" Background="#FFFFFFFF" BorderThickness="1" CornerRadius="2" Padding="0" Visibility="Collapsed">
                                    <Border.BorderBrush>
                                        <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
                                            <GradientStop Color="#FFABAEB3" Offset="0"/>