<Style x:Key="ComboBoxStyle" TargetType="{x:Type ComboBox}">
   <Setter Property="FocusVisualStyle" Value="{StaticResource ComboBoxFocusVisual}"/>
   <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.WindowTextBrushKey}}"/>
   <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
   <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
   <Setter Property="BorderThickness" Value="1"/>
   <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
   <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
   <Setter Property="Padding" Value="4,3"/>
   <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
   <Setter Property="ScrollViewer.PanningMode" Value="Both"/>
   <Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
   <Setter Property="Template">
    <Setter.Value>
     <ControlTemplate TargetType="{x:Type ComboBox}">
      <Grid x:Name="MainGrid" SnapsToDevicePixels="true">
       <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition MinWidth="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}" Width="0"/>
       </Grid.ColumnDefinitions>
       <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
         <VisualState x:Name="Normal"/>
         <VisualState x:Name="MouseOver"/>
         <VisualState x:Name="Disabled"/>
        </VisualStateGroup>
        <VisualStateGroup x:Name="FocusStates">
         <VisualState x:Name="Unfocused"/>
         <VisualState x:Name="Focused"/>
         <VisualState x:Name="FocusedDropDown"/>
        </VisualStateGroup>
        <VisualStateGroup x:Name="EditStates">
         <VisualState x:Name="Editable"/>
         <VisualState x:Name="Uneditable"/>
        </VisualStateGroup>
        <VisualStateGroup x:Name="ValidationStates">
         <VisualState x:Name="Valid"/>
         <VisualState x:Name="InvalidFocused"/>
         <VisualState x:Name="InvalidUnfocused"/>
        </VisualStateGroup>
       </VisualStateManager.VisualStateGroups>
       <VisualStateManager.CustomVisualStateManager>
        <ei:ExtendedVisualStateManager/>
       </VisualStateManager.CustomVisualStateManager>
       <Popup x:Name="PART_Popup" AllowsTransparency="true" Grid.ColumnSpan="2" IsOpen="{Binding IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}" Margin="1" PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}" Placement="Bottom">
        <Microsoft_Windows_Themes:SystemDropShadowChrome x:Name="Shdw" Color="Transparent" MaxHeight="{TemplateBinding MaxDropDownHeight}" MinWidth="{Binding ActualWidth, ElementName=MainGrid}" OpacityMask="Black">
         <Border x:Name="DropDownBorder" BorderThickness="1" Background="#FF434343">
          <ScrollViewer x:Name="DropDownScrollViewer">
           <Grid RenderOptions.ClearTypeHint="Enabled">
            <Canvas HorizontalAlignment="Left" Height="0" VerticalAlignment="Top" Width="0">
             <Rectangle x:Name="OpaqueRect" Height="{Binding ActualHeight, ElementName=DropDownBorder}" Width="{Binding ActualWidth, ElementName=DropDownBorder}" Fill="#FFC7C7C7"/>
            </Canvas>
            <ItemsPresenter x:Name="ItemsPresenter" KeyboardNavigation.DirectionalNavigation="Contained" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" OpacityMask="#FF777777"/>
           </Grid>
          </ScrollViewer>
         </Border>
        </Microsoft_Windows_Themes:SystemDropShadowChrome>
       </Popup>
       <ToggleButton Grid.ColumnSpan="2" IsChecked="{Binding IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}" Style="{DynamicResource ToggleButtonStyle}" Background="#FF777777" BorderBrush="#FF434343" Width="Auto"/>
       <ContentPresenter ContentTemplate="{TemplateBinding SelectionBoxItemTemplate}" ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}" Content="{TemplateBinding SelectionBoxItem}" ContentStringFormat="{TemplateBinding SelectionBoxItemStringFormat}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsHitTestVisible="false" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" OpacityMask="#FF777777"/>
      </Grid>
      <ControlTemplate.Triggers>
       <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>
       <Trigger Property="HasItems" Value="false">
        <Setter Property="Height" TargetName="DropDownBorder" Value="95"/>
        <Setter Property="BorderBrush" TargetName="DropDownBorder" Value="#FF777777"/>
       </Trigger>
       <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
        <Setter Property="Background" Value="#FFF4F4F4"/>
       </Trigger>
       <Trigger Property="IsGrouping" Value="true">
        <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
       </Trigger>
       <Trigger Property="ScrollViewer.CanContentScroll" SourceName="DropDownScrollViewer" Value="false">
        <Setter Property="Canvas.Top" TargetName="OpaqueRect" Value="{Binding VerticalOffset, ElementName=DropDownScrollViewer}"/>
        <Setter Property="Canvas.Left" TargetName="OpaqueRect" Value="{Binding HorizontalOffset, ElementName=DropDownScrollViewer}"/>
       </Trigger>
      </ControlTemplate.Triggers>
     </ControlTemplate>
    </Setter.Value>
   </Setter>
   <Style.Triggers>
    <Trigger Property="IsEditable" Value="true">
     <Setter Property="BorderBrush" Value="{StaticResource TextBoxBorder}"/>
     <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
     <Setter Property="IsTabStop" Value="false"/>
     <Setter Property="Padding" Value="3"/>
     <Setter Property="Template" Value="{StaticResource ComboBoxEditableTemplate}"/>
    </Trigger>
   </Style.Triggers>
  </Style>
  <Style x:Key="ToggleButtonStyle" TargetType="{x:Type ToggleButton}">
   <Setter Property="OverridesDefaultStyle" Value="true"/>
   <Setter Property="IsTabStop" Value="false"/>
   <Setter Property="Focusable" Value="false"/>
   <Setter Property="ClickMode" Value="Press"/>
   <Setter Property="Template">
    <Setter.Value>
     <ControlTemplate TargetType="{x:Type ToggleButton}">
      <Microsoft_Windows_Themes:ButtonChrome x:Name="Chrome" SnapsToDevicePixels="true" Background="#FF777777" BorderBrush="#FF777777" RenderMouseOver="False">
       <VisualStateManager.VisualStateGroups>
        <VisualStateGroup x:Name="CommonStates">
         <VisualState x:Name="Normal"/>
         <VisualState x:Name="MouseOver"/>
         <VisualState x:Name="Pressed"/>
         <VisualState x:Name="Disabled"/>
        </VisualStateGroup>
       </VisualStateManager.VisualStateGroups>
       <Grid HorizontalAlignment="Right" Width="{DynamicResource {x:Static SystemParameters.VerticalScrollBarWidthKey}}">
        <Path x:Name="Arrow" Data="{StaticResource DownArrowGeometry}" Fill="Black" HorizontalAlignment="Center" Margin="3,1,0,0" VerticalAlignment="Center"/>
       </Grid>
      </Microsoft_Windows_Themes:ButtonChrome>
      <ControlTemplate.Triggers>
       <Trigger Property="IsEnabled" Value="false">
        <Setter Property="Fill" TargetName="Arrow" Value="#AFAFAF"/>
       </Trigger>
       <Trigger Property="IsChecked" Value="False"/>
       <EventTrigger RoutedEvent="FrameworkElement.Loaded"/>
      </ControlTemplate.Triggers>
     </ControlTemplate>
    </Setter.Value>
   </Setter>
  </Style>

ComboBoxStyle和ToggleButton的更多相关文章

  1. Third Day:正式编程第三天,学习实践内容TextView跑马灯、AutoCompleteTextView、multiAutoCompleteTextView以及ToggleButton、checkedBox、RadioButton等相关实践

    2.针对Focused的TextView跑马灯(文字较多一行无法显示)效果 针对单个TextView的跑马灯效果,可直接在TextView控件参数中添加三个属性: android:singleLine ...

  2. 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    [源码下载] 背水一战 Windows 10 (31) - 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButt ...

  3. android控件 ToggleButton的应用

    ToggleButton是android给我们提供的开关按钮, 有两种状态:选中和未选择状态. 以下是代码实例: main.xml [html] view plain copy <?xml ve ...

  4. EUI ToggleButton ToggleSwitch 实现类似音乐开关按钮

    一 ToggleButton和ToggleSwitch区别 没区别,就是继承... export class ToggleSwitch extends ToggleButton { /** * @la ...

  5. 状态开关按钮(ToggleButton)和开关(Switch)

    ToggleButton支持的XML属性及相关方法1.android:checked----->setChecked(boolean) ----->设置该按钮是否被选中2.android: ...

  6. 控件(按钮类): ButtonBase, Button, HyperlinkButton, RepeatButton, ToggleButton, AppBarButton, AppBarToggleButton

    介绍背水一战 Windows 10 之 控件(按钮类) ButtonBase Button HyperlinkButton RepeatButton ToggleButton AppBarButton ...

  7. Android成长日记-使用ToggleButton实现灯的开关

    案例演示 此案例实现思路:通过ToggleButton控件,ImageView控件实现 ---xml代码: <!-- textOn:true textOff:falase[s1] --> ...

  8. Android --ToggleButton的使用

    1. 效果图

  9. 6.Android之switch和togglebutton按钮学习

    Switch和ToggleButton按钮在手机上也经常看到,比如手机设置里面wlan,蓝牙,gps开关等. 首先在工具上拖进一个switch和togglebutton开关按钮,如图 生成xml代码如 ...

随机推荐

  1. sql的reader方法注意事项

    如果恢复注释. 在数据只有一条时,list将始终为空 原因很简单. 第一个红框已经跑完了.第二次调用的时候,就是第二条了,此时数据为空

  2. 洛谷 P4109 [HEOI2015]定价

    洛谷 这是今天的考试题,我来发一波- 看L和R的范围,显然不能一个一个加,这样会有很多重复情况,会超时,只要看该数有多少个后导0,就把L加上10的多少次方. 很容易可以想到价格后面尽可能多0, 在此基 ...

  3. Servlet 运行原理

    一:servlet定义 Servlet是一个Java应用程序,运行在服务器端,用来处理客户端请求并作出响应的程序. 二:简单servlet实例 //导入所需的包 import javax.servle ...

  4. Python正则表达式基础

    1. 正则表达式基础 1.1. 简单介绍 正则表达式并不是Python的一部分.正则表达式是用于处理字符串的强大工具,拥有自己独特的语法以及一个独立的处理引擎,效率上可能不如str自带的方法,但功能十 ...

  5. 修改mysql root的密码

    use mysql:update user set Password = Password('newPwd') where user='root';//更改root用户的密码flush privile ...

  6. studio显示Surface: getSlotFromBufferLocked: unknown buffer: 0xa2a58be0

    根据查询外网资料来看,出现这个错误的原因大致是换个模拟器或者物理机就可以了. 因为我使用的是安卓6.0,貌似都会出现这类的问题. 但是不影响程序运行.

  7. 玩转git版本控制软件

    一.git的基本介绍 1.什么是git? git是个开源的分布式版本控制软件,用以有效.高速的处理从很小到非常大的项目版本管理.说白了就是个版本控制软件 2.git的使用方法 git软件是通过命令来实 ...

  8. Manacher专题

    1.POJ 3974 Palindrome 题意:求一个长字符串的最长回文子串. 思路:Manacher模板. #include<iostream> #include<algorit ...

  9. chrome浏览器插件让你浏览github的时候像IDE一样提供项目目录

    GitHub 作为代码托管平台,竟然没有提供项目目录,方便用户在线快速浏览项目结构.所以,在线分析项目源码就会变得很繁琐,必须一层一层点击,然后再一次一次地向上返回.要知道,本来 GitHub 网站在 ...

  10. windows下docker toolbox无法下载boot2docker.iso

    GitHub连不上导致自动更新失败.(网络形势严峻!) 通过别的途径手动下载了指定的最新的boot2docker.iso文件.(比方说迅雷!比方说迅雷!比方说迅雷!) https://github.c ...