当前位置: 代码迷 >> .NET Framework >> 怎么修改选中菜单左侧对勾的默认颜色
  详细解决方案

怎么修改选中菜单左侧对勾的默认颜色

热度:126   发布时间:2016-05-01 23:32:21.0
如何修改选中菜单左侧对勾的默认颜色

我知道是通过样式模板进行修改,却不清楚是修改的是哪个样式属性,请各位同仁
帮我一下哦,在此感谢!
------解决方案--------------------


生成一个新的MenuItem模版 之后把样式加到想要改变颜色的MenuItem上


<ControlTemplate x:Key="MenuItemControlTemplate1" TargetType="{x:Type MenuItem}">
            <Themes:ClassicBorderDecorator x:Name="ClassicBorder" BorderBrush="#00000000" BorderThickness="1" BorderStyle="None" Background="{TemplateBinding Background}">
                <DockPanel>
                    <ContentPresenter x:Name="Icon" Content="{TemplateBinding Icon}" ContentSource="Icon" Margin="4,0,6,0" VerticalAlignment="Center"/>
                    <Path x:Name="GlyphPanel" Data="M0,2 L0,4.8 L2.5,7.4 L7.1,2.8 L7.1,0 L2.5,4.6 z" Fill="Red" FlowDirection="LeftToRight" Margin="4,0,6,0" Visibility="Collapsed" VerticalAlignment="Center"/>
                    <ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True"/>
                    <Popup x:Name="PART_Popup" AllowsTransparency="True" Focusable="False" HorizontalOffset="-2" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom">
                        <Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent">
                            <Themes:ClassicBorderDecorator x:Name="SubMenuBorder" BorderBrush="#00000000" BorderThickness="2" BorderStyle="AltRaised" Background="{DynamicResource {x:Static SystemColors.ControlBrushKey}}">
                                <ScrollViewer x:Name="SubMenuScrollViewer" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
                                    <Grid RenderOptions.ClearTypeHint="Enabled">
                                        <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
                                            <Rectangle x:Name="OpaqueRect" Fill="{Binding Background, ElementName=SubMenuBorder}" Height="{Binding ActualHeight, ElementName=SubMenuBorder}" Width="{Binding ActualWidth, ElementName=SubMenuBorder}"/>
                                        </Canvas>
                                        <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True" KeyboardNavigation.TabNavigation="Cycle"/>
                                    </Grid>
                                </ScrollViewer>
                            </Themes:ClassicBorderDecorator>
                        </Themes:SystemDropShadowChrome>
  相关解决方案