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>
  • 相关阅读:
    一起学Vue之表单输入绑定
    简单易懂的单元测试框架-gtest(二)
    简单易懂的单元测试框架-gtest(一)
    最常用设计模式-模板方法模式
    最常用设计模式-简单工厂模式
    最常用设计模式-单例模式
    端口复用后门
    内存取证工具-volatility、foremost
    python的exe反编译
    Linux加密known_hosts文件中的IP
  • 原文地址:https://www.cnblogs.com/dotnetHui/p/8532353.html
Copyright © 2011-2022 走看看