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>
  • 相关阅读:
    常用的npm指令总结
    Mongoose基础
    2016总结与展望
    sleep与wait的区别
    查询平均分大于80分的学生
    求最大不重复子串
    快速排序
    按位与(&)运算的作用
    异或运算的作用
    java 字符串中的每个单词的倒序输出
  • 原文地址:https://www.cnblogs.com/w2011/p/3224948.html
Copyright © 2011-2022 走看看