zoukankan      html  css  js  c++  java
  • 简单使用控件模板2

    简单使用控件模板

    <Window.Resources>
            <ControlTemplate x:Key="buttontemplate" TargetType="{x:Type Button}">
                <Border BorderBrush="Orange" BorderThickness="{TemplateBinding Button.BorderThickness}" CornerRadius="3"
                        Background="Red" TextBlock.Foreground="Black" Margin="30">
                    <ContentPresenter RecognizesAccessKey="True" HorizontalAlignment="Center"
                                       VerticalAlignment="Center" Content="{TemplateBinding Button.Content}"></ContentPresenter>
                </Border>
            </ControlTemplate>
        </Window.Resources>
        <StackPanel>
            <Button FontSize="15" Template="{StaticResource ResourceKey=buttontemplate}" BorderThickness="10" Content="Hello"></Button>
            <Button FontSize="15" Template="{StaticResource ResourceKey=buttontemplate}" BorderThickness="4" Content="您好"></Button>
        </StackPanel>

    控件模板触发器

    <Window.Resources>
            <ControlTemplate x:Key="buttontemplate" TargetType="{x:Type Button}">
                <Border Name="border" BorderBrush="Orange" BorderThickness="{TemplateBinding Button.BorderThickness}" CornerRadius="3"
                        Background="Red" TextBlock.Foreground="Black" Margin="30">
                    <StackPanel>
                            <Rectangle Name="FocusCue" Visibility="Hidden" Stroke="Black"
                                        StrokeThickness="3" StrokeDashArray="1 2" SnapsToDevicePixels="True"></Rectangle>
                     
                        <ContentPresenter RecognizesAccessKey="True" HorizontalAlignment="Center"
                                           VerticalAlignment="Center" Content="{TemplateBinding Button.Content}">
                       
                        </ContentPresenter>
                    </StackPanel>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="true">
                        <Setter TargetName="border" Property="Background" Value="White"/>
                    </Trigger>
                    <Trigger Property="IsPressed" Value="True">
                        <Setter TargetName="FocusCue" Property="Visibility" Value="Visible"/>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
           
        </Window.Resources>
        <StackPanel>
            <Button Template="{StaticResource ResourceKey=buttontemplate}" Content="Hello"/>
        </StackPanel>

  • 相关阅读:
    docker学习
    redis哨兵部署
    HUE中一些重要元数据表的DDL整理
    Autosys中ON_HOLD和ON_ICE的区别
    Spark结构化API的执行过程——Logical Plan & Physical Plan
    关于Spark中Columns的引用方法
    关于Spark Dataset API中的Typed transformations和Untyped transformations
    关于Kafka Consumer 与 Partitions
    使用sed根据变量值注释掉文件中相匹配的记录行
    sqoop export to teradata时出现java.lang.NullPointerException
  • 原文地址:https://www.cnblogs.com/KimhillZhang/p/2422493.html
Copyright © 2011-2022 走看看