zoukankan      html  css  js  c++  java
  • wpf 纯样式写按钮

     1 <!--自定义按钮样式-->
     2      <LinearGradientBrush x:Key="LinearGradientBlueBackground" EndPoint="0.5,1" StartPoint="0.5,0">
     3             <GradientStop Color="#FF377FED" Offset="0" />
     4             <GradientStop Color="#FF074CC0" Offset="1" />
     5         </LinearGradientBrush>
     6     <SolidColorBrush x:Key="MyBtnBorderColor" Color="#FF2D78F4" />
     7     <SolidColorBrush x:Key="MyBtnHoverBackgroundColor" Color="#3096FF" />
     8     <SolidColorBrush x:Key="MyBtnPressedBackgroundColor" Color="#0067CF" />
     9     <!--END-->
    10         
    11         <Style x:Key="StlLoginBtnStyle" TargetType="{x:Type Button}" >
    12         <Setter Property="Background" Value="{StaticResource LinearGradientBlueBackground}" />
    13         <Setter Property="Foreground" Value="#FFFFFF" />
    14         <Setter Property="FontSize" Value="36" />
    15         <Setter Property="FontFamily" Value="MicrosoftYaHei" />
    16         <Setter Property="Width" Value="560" />
    17         <Setter Property="Height" Value="100" />
    18         <Setter Property="BorderBrush" Value="{StaticResource MyBtnBorderColor}" />
    19         <Setter Property="Template">
    20                 <Setter.Value>
    21                     <ControlTemplate TargetType="{x:Type Button}">
    22                         <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" 
    23                                 SnapsToDevicePixels="true" CornerRadius="3,3,3,3">
    24                         <ContentPresenter x:Name="contentPresenter" 
    25                                               Focusable="False" 
    26                                               HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
    27                                               Margin="{TemplateBinding Padding}" 
    28                                               RecognizesAccessKey="True" 
    29                                               SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
    30                                               VerticalAlignment="{TemplateBinding VerticalContentAlignment}"  Content="立即登录"/>
    31                     </Border>
    32                         <ControlTemplate.Triggers>
    33                             <Trigger Property="IsMouseOver" Value="true">
    34                                 <Setter Property="Background" TargetName="border" Value="{StaticResource MyBtnHoverBackgroundColor}"/>
    35                             </Trigger>
    36                         <Trigger Property="IsPressed" Value="true">
    37                             <Setter Property="Background" TargetName="border" Value="{StaticResource MyBtnPressedBackgroundColor}" />
    38                         </Trigger>
    39                         </ControlTemplate.Triggers>
    40                     </ControlTemplate>
    41                 </Setter.Value>
    42             </Setter>
    43         </Style>
  • 相关阅读:
    设计模式之工厂模式-抽象工厂(02)
    1036 跟奥巴马一起编程 (15 分)
    1034 有理数四则运算 (20 分)
    1033 旧键盘打字 (20 分)
    1031 查验身份证 (15 分)
    大学排名定向爬虫
    1030 完美数列 (25 分)二分
    1029 旧键盘 (20 分)
    1028 人口普查 (20 分)
    1026 程序运行时间 (15 分)四舍五入
  • 原文地址:https://www.cnblogs.com/dotnetHui/p/8532353.html
Copyright © 2011-2022 走看看