zoukankan      html  css  js  c++  java
  • wpf menuitem 简约显示的 template样式


    <ControlTemplate x:Key="MenuItemControlTemplate1" TargetType="{x:Type MenuItem}">
    <Grid SnapsToDevicePixels="True">
    <Border x:Name="OuterBorder" BorderThickness="0,0,0,0.7" BorderBrush="White"/>
    <DockPanel>
    <TextBlock x:Name="TextContent" HorizontalAlignment="Center">
    <ContentPresenter ContentTemplate="{TemplateBinding HeaderTemplate}" Content="{TemplateBinding Header}" ContentStringFormat="{TemplateBinding HeaderStringFormat}" ContentSource="Header" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
    </TextBlock>
    </DockPanel>
    <Popup x:Name="PART_Popup" AllowsTransparency="True" Margin="0" Focusable="False" HorizontalOffset="1" IsOpen="{Binding IsSubmenuOpen, RelativeSource={RelativeSource TemplatedParent}}" PopupAnimation="{DynamicResource {x:Static SystemParameters.MenuPopupAnimationKey}}" Placement="Bottom" VerticalOffset="-1">
    <Themes:SystemDropShadowChrome x:Name="Shdw" Color="#535865">
    <Border x:Name="SubMenuBorder" BorderBrush="#FF959595" BorderThickness="0">
    <ScrollViewer x:Name="SubMenuScrollViewer" Margin="0" Padding="0" BorderThickness="0" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}">
    <Grid RenderOptions.ClearTypeHint="Enabled" ShowGridLines="True" Background="#535865">
    <StackPanel IsItemsHost="True"
    KeyboardNavigation.DirectionalNavigation="Cycle" Width="100"/>
    </Grid>
    </ScrollViewer>
    </Border>
    </Themes:SystemDropShadowChrome>
    </Popup>
    </Grid>
    <ControlTemplate.Triggers>
    <Trigger Property="IsSuspendingPopupAnimation" Value="True">
    <Setter Property="PopupAnimation" TargetName="PART_Popup" Value="None"/>
    </Trigger>
    <Trigger Property="IsHighlighted" Value="True">
    <Setter Property="Foreground" TargetName="TextContent" Value="#54FFFF"/>
    <Setter Property="BorderBrush" TargetName="OuterBorder" Value="Red"/>
    <Setter Property="BorderThickness" TargetName="OuterBorder" Value="1"/>
    </Trigger>
    <Trigger Property="HasDropShadow" SourceName="PART_Popup" Value="True">
    <Setter Property="Margin" TargetName="Shdw" Value="0,0,5,5"/>
    <Setter Property="Color" TargetName="Shdw" Value="#71000000"/>
    </Trigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>

    效果图如下

  • 相关阅读:
    prism.js——让网页中的代码更好看
    WebAPI之FormData
    ES6背记手册
    搭建本地的百度脑图
    webpack到底是干什么用的?
    浅拷贝和深拷贝
    vue 中使用 watch 的各种问题
    跳一跳外挂的python实现--OpenCV步步精深
    Opencv基础课必须掌握:滑动条做调色盘 -OpenCV步步精深
    Opencv稍微高级点的鼠标事件-OpenCV步步精深
  • 原文地址:https://www.cnblogs.com/tianmochou/p/11392782.html
Copyright © 2011-2022 走看看