zoukankan      html  css  js  c++  java
  • WPF资源使用

    <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        >
            <Style x:Key="EmptyButton" TargetType="Button">
                <Setter Property="Focusable" Value="False" />
                <Setter Property="IsTabStop" Value="False" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="Button">
                            <Grid Background="#00FF0000" 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>
                                <ContentPresenter Content="{TemplateBinding Content}" 
                                                  ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                            </Grid>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    </ResourceDictionary>

    重写Button

    然后在界面调用

        <UserControl.Resources>
            <ResourceDictionary>
                <ResourceDictionary.MergedDictionaries>
                    <ResourceDictionary Source="../Theme/EmptyButton.xaml" />
                </ResourceDictionary.MergedDictionaries>
           </ResourceDictionary>
        </UserControl.Resources>
  • 相关阅读:
    win10彻底永久关闭自动更新的方法
    kibana.yml配置
    完整记录安装elasticsearch的过程
    docker下nginx的安装
    centos7删除mysql
    21 | panic函数、recover函数以及defer语句 (上)
    07 | 数组和切片
    SNAPSHOT包上传nexus成功,下载失败
    extract method(提炼函数)
    枚举中不要再出现数字了
  • 原文地址:https://www.cnblogs.com/w2011/p/3224948.html
Copyright © 2011-2022 走看看