WPF:MenuItem样式

 

基础信息

1、MenuItem 样式

    

        

        
        "toolsDS" Source="Config\Tools\Tools.xml" XPath="Tools/Tool">
        
        "Tool" ItemsSource="{Binding XPath=Tool}" >
            "Horizontal">
                "{Binding XPath=@Name}" Width="38">
                    "{Binding XPath=@ImagePath}" Width="38" Height="38">
                
            
        
        
        
        
    
    
    
View Code

2、Menu、MenuItem、 直接拷贝就可查看示例

    

        
        "WindowColor">#FFE8EDF9
        "ContentAreaColorLight">#FFC5CBF9
        "ContentAreaColorDark">#FF7381F9

        "DisabledControlLightColor">#FFE8EDF9
        "DisabledControlDarkColor">#FFC5CBF9
        "DisabledForegroundColor">#FF888888

        "SelectedBackgroundColor">#FFC5CBF9
        "SelectedUnfocusedColor">#FFDDDDDD

        "ControlLightColor">White
        "ControlMediumColor">#FF7381F9
        "ControlDarkColor">#FF211AA9

        "ControlMouseOverColor">#FF3843C4
        "ControlPressedColor">#FF211AA9


        "GlyphColor">#FF444444
        "GlyphMouseOver">sc#1, 0.004391443, 0.002428215, 0.242281124

        
        "BorderLightColor">#FFCCCCCC
        "BorderMediumColor">#FF888888
        "BorderDarkColor">#FF444444

        "PressedBorderLightColor">#FF888888
        "PressedBorderDarkColor">#FF444444

        "DisabledBorderLightColor">#FFAAAAAA
        "DisabledBorderDarkColor">#FF888888

        "DefaultBorderBrushDarkColor">Black

        
        "HeaderTopColor">#FFC5CBF9
        "DatagridCurrentCellBorderColor">Black
        "SliderTrackDarkColor">#FFC5CBF9

        "NavButtonFrameColor">#FF3843C4

        "MenuPopupBrush"
                     EndPoint="0.5,1"
                     StartPoint="0.5,0">
            "{DynamicResource ControlLightColor}"
                Offset="0" />
            "{DynamicResource ControlMediumColor}"
                Offset="0.5" />
            "{DynamicResource ControlLightColor}"
                Offset="1" />
        

        "ProgressBarIndicatorAnimatedFill"
                     StartPoint="0,0"
                     EndPoint="1,0">
            
                
                    "#000000FF"
                    Offset="0" />
                    "#600000FF"
                    Offset="0.4" />
                    "#600000FF"
                    Offset="0.6" />
                    "#000000FF"
                    Offset="1" />
                
            
        


        

        
        
        
       


        
        "MenuScrollingVisibilityConverter" />

        



        
"{x:Static MenuItem.TopLevelHeaderTemplateKey}"
                 TargetType="{x:Type MenuItem}">
  "Border">
    
      "6,3,6,3"
                        ContentSource="Header"
                        RecognizesAccessKey="True" />
      "Popup"
             Placement="Bottom"
             IsOpen="{TemplateBinding IsSubmenuOpen}"
             AllowsTransparency="True"
             Focusable="False"
             PopupAnimation="Fade">
        "SubmenuBorder"
                SnapsToDevicePixels="True"
                BorderThickness="1"
                Background="{DynamicResource MenuPopupBrush}">
          
            "{DynamicResource BorderMediumColor}" />
          
          "True"
                        Style="{StaticResource MenuScrollViewer}">
            "True"
                        KeyboardNavigation.DirectionalNavigation="Cycle" />
          
        
      
    
  
  
    "IsSuspendingPopupAnimation"
             Value="true">
      "Popup"
              Property="PopupAnimation"
              Value="None" />
    
    "IsHighlighted"
             Value="true">
      "Border"
              Property="BorderBrush"
              Value="Transparent" />
      "Background"
              TargetName="Border">
        
          "0,0"
                               EndPoint="0,1">
            
              
                "{StaticResource ControlLightColor}" />
                "{StaticResource ControlMouseOverColor}"
                              Offset="1.0" />
              
            
          

        
      
    
    "Popup"
             Property="AllowsTransparency"
             Value="True">
      "SubmenuBorder"
              Property="CornerRadius"
              Value="0,0,4,4" />
      "SubmenuBorder"
              Property="Padding"
              Value="0,0,0,3" />
    
    "IsEnabled"
             Value="False">
      "Foreground">
        
          "{StaticResource DisabledForegroundColor}" />
        
      
    
  



"{x:Static MenuItem.TopLevelItemTemplateKey}"
                 TargetType="{x:Type MenuItem}">
  "Border">
    
      "6,3,6,3"
                        ContentSource="Header"
                        RecognizesAccessKey="True" />
    
  
  
    "IsHighlighted"
             Value="true">
      "Background"
              TargetName="Border">
        
          "0,0"
                               EndPoint="0,1">
            
              
                "{StaticResource ControlLightColor}" />
                "{StaticResource ControlMouseOverColor}"
                              Offset="1.0" />
              
            
          

        
      
    
    "IsEnabled"
             Value="False">
      "Foreground">
        
          "{StaticResource DisabledForegroundColor}" />
        
      
    
  



"{x:Static MenuItem.SubmenuItemTemplateKey}"
                 TargetType="{x:Type MenuItem}">
  "Border"
          BorderThickness="1">
    
      
        
        "*" />
        
      
      "Icon"
                        Margin="6,0,6,0"
                        VerticalAlignment="Center"
                        ContentSource="Icon" />
      "Check"
              Width="13"
              Height="13"
              Visibility="Collapsed"
              Margin="6,0,6,0"
              BorderThickness="1">
        
          "0,0"
                               EndPoint="0,1">
            
              
                "{DynamicResource BorderLightColor}"
                              Offset="0.0" />
                "{DynamicResource BorderDarkColor}"
                              Offset="1.0" />
              
            
          

        
        
          "0,0"
                               EndPoint="0,1">
            
              
                "{DynamicResource ControlLightColor}" />
                "{DynamicResource ControlMediumColor}"
                              Offset="1.0" />
              
            
          
        
        "CheckMark"
              Width="7"
              Height="7"
              Visibility="Hidden"
              SnapsToDevicePixels="False"
              StrokeThickness="2"
              Data="M 0 0 L 7 7 M 0 7 L 7 0">
          
            "{DynamicResource GlyphColor}" />
          
        
      
      "HeaderHost"
                        Grid.Column="1"
                        ContentSource="Header"
                        RecognizesAccessKey="True" />
      "InputGestureText"
                 Grid.Column="2"
                 Text="{TemplateBinding InputGestureText}"
                 Margin="5,2,0,2"
                 DockPanel.Dock="Right" />
    
  
  
    "ButtonBase.Command"
             Value="{x:Null}" />
    "Icon"
             Value="{x:Null}">
      "Icon"
              Property="Visibility"
              Value="Hidden" />
    
    "IsChecked"
             Value="true">
      "CheckMark"
              Property="Visibility"
              Value="Visible" />
    
    "IsCheckable"
             Value="true">
      "Check"
              Property="Visibility"
              Value="Visible" />
      "Icon"
              Property="Visibility"
              Value="Hidden" />
    
    "IsHighlighted"
             Value="true">
      "Background"
              TargetName="Border">
        
          "0.5,1"
                               StartPoint="0.5,0">
            "Transparent"
                          Offset="0" />
            "{DynamicResource ControlMouseOverColor}"
                          Offset="1" />
          
        
      
      "BorderBrush"
              TargetName="Border">
        
          "0.5,1"
                               StartPoint="0.5,0">
            "{DynamicResource BorderMediumColor}"
                          Offset="0" />
            "Transparent"
                          Offset="1" />
          
        
      
    
    "IsEnabled"
             Value="false">
      "Foreground">
        
          "{StaticResource DisabledForegroundColor}" />
        
      
    
  


"{x:Static MenuItem.SubmenuHeaderTemplateKey}"
                 TargetType="{x:Type MenuItem}">
  "Border"
          BorderThickness="1">
    
      
        "Auto"
                          SharedSizeGroup="Icon" />
        "*" />
        "Auto"
                          SharedSizeGroup="Shortcut" />
        "13" />
      
      "Icon"
                        Margin="6,0,6,0"
                        VerticalAlignment="Center"
                        ContentSource="Icon" />
      "HeaderHost"
                        Grid.Column="1"
                        ContentSource="Header"
                        RecognizesAccessKey="True" />
      "InputGestureText"
                 Grid.Column="2"
                 Text="{TemplateBinding InputGestureText}"
                 Margin="5,2,2,2"
                 DockPanel.Dock="Right" />
      "3"
            HorizontalAlignment="Center"
            VerticalAlignment="Center"
            Data="M 0 0 L 0 7 L 4 3.5 Z">
        
          "{DynamicResource GlyphColor}" />
        
      
      "Popup"
             Placement="Right"
             HorizontalOffset="-4"
             IsOpen="{TemplateBinding IsSubmenuOpen}"
             AllowsTransparency="True"
             Focusable="False"
             PopupAnimation="Fade">
        "SubmenuBorder"
                SnapsToDevicePixels="True"
                Background="{DynamicResource MenuPopupBrush}"
                BorderThickness="1">
          
            "{DynamicResource BorderMediumColor}" />
          
          "True"
                        Style="{StaticResource MenuScrollViewer}">
            "True"
                        KeyboardNavigation.DirectionalNavigation="Cycle" />
          
        
      
    
  
  
    "Icon"
             Value="{x:Null}">
      "Icon"
              Property="Visibility"
              Value="Collapsed" />
    
    "IsHighlighted"
             Value="true">
      "Background"
              TargetName="Border">
        
          "0.5,1"
                               StartPoint="0.5,0">
            "Transparent"
                          Offset="0" />
            "{DynamicResource ControlMouseOverColor}"
                          Offset="1" />
          
        
      
      "BorderBrush"
              TargetName="Border">
        
          "0.5,1"
                               StartPoint="0.5,0">
            "{DynamicResource BorderMediumColor}"
                          Offset="0" />
            "Transparent"
                          Offset="1" />
          
        
      
    
    "Popup"
             Property="AllowsTransparency"
             Value="True">
      "SubmenuBorder"
              Property="CornerRadius"
              Value="4" />
      "SubmenuBorder"
              Property="Padding"
              Value="0,3,0,3" />
    
    "IsEnabled"
             Value="false">
      "Foreground">
        
          "{StaticResource DisabledForegroundColor}" />
        
      
    
  









        "menudata" Source="Config\Tools\MenuData.xml" XPath="MenuData/Operation">
        "Operation"
                                  ItemsSource="{Binding XPath=Operation}">
            "Horizontal" >
                "{Binding XPath=@Name}" HorizontalAlignment="Left">
                "{Binding XPath=@Gesture}" HorizontalAlignment="Left">
            

        
    
View Code

 

转载于:https://www.cnblogs.com/shenchao/p/5411742.html

你可能感兴趣的:(WPF:MenuItem样式)