zoukankan      html  css  js  c++  java
  • WPF CheckBox 自定义样式

     WPF 自定义样式。CheckBox

        <Style x:Key="EmptyCheckBox" TargetType="CheckBox">
            <Setter  Property="Focusable" Value="False"/>
            <Setter Property="IsTabStop" Value="False" />
            <Setter Property="Height" Value="32"/>
            <Setter Property="OverridesDefaultStyle" Value="True"/>
            <Style.Triggers>
                <Trigger Property="IsChecked" Value="True">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="CheckBox">
                                <Grid Background="Transparent" Cursor="Hand">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Disabled" />
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="MouseOver" />
                                            <VisualState x:Name="Pressed" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Image Source="/FZHotel.MatroUIApp;component/Images/Button/check_ok.png"></Image>
                                    <ContentPresenter Content="{TemplateBinding Content}" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="IsChecked" Value="False">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="CheckBox">
                                <Grid Background="Transparent" Cursor="Hand">
                                    <VisualStateManager.VisualStateGroups>
                                        <VisualStateGroup x:Name="CommonStates">
                                            <VisualState x:Name="Disabled" />
                                            <VisualState x:Name="Normal" />
                                            <VisualState x:Name="MouseOver" />
                                            <VisualState x:Name="Pressed" />
                                        </VisualStateGroup>
                                    </VisualStateManager.VisualStateGroups>
                                    <Image Source="/FZHotel.MatroUIApp;component/Images/Button/check_cancel.png"></Image>
                                    <ContentPresenter Content="{TemplateBinding Content}" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                </Grid>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                 </Trigger>
            </Style.Triggers>
        </Style>
  • 相关阅读:
    gitlab安装配置
    jenkins忘记admin密码的处理方法
    jenkins权限管理插件role-based(二)
    jenkins安装部署(一)
    ERROR 1129 (HY000): Host '192.168.7.210' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'
    nginx重试机制proxy_next_upstream
    nginx配置ssi
    python实现查找指定文件
    python 调用系统命令
    Android 调用资源字符串的几种方法
  • 原文地址:https://www.cnblogs.com/w2011/p/3253011.html
Copyright © 2011-2022 走看看