记录一些WPF常用样式方便以后复用(二)(Button、CheckBox、输入账号密码框)(转)
Button (一)

- <Style x:Key="ButtonSaveStyle" TargetType="{x:Type Button}">
- <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
- <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
- <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="HorizontalContentAlignment" Value="Center"/>
- <Setter Property="VerticalContentAlignment" Value="Center"/>
- <Setter Property="Padding" Value="1"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border x:Name="Chrome" CornerRadius="5" Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" >
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
- </Border>
- <!--<Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" RenderDefaulted="{TemplateBinding IsDefaulted}" SnapsToDevicePixels="true">
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
- </Themes:ButtonChrome>-->
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter Property="Background" TargetName="Chrome" Value="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
- </Trigger>
- <Trigger Property="IsEnabled" Value="false">
- <Setter Property="Foreground" Value="#ADADAD"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <!--Background为背景颜色,BorderBrush为鼠标移入的背景-->
- <Button Width="100" Height="35" VerticalAlignment="Top" Background="#FFFD5F4F" BorderBrush="#FFEC685C" Content="保存" Style="{DynamicResource ButtonSaveStyle}" Foreground="White" TextOptions.TextFormattingMode="Display" FontSize="13.333"/>

Button(二)

- <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
- <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
- <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
- <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
- <Setter Property="BorderThickness" Value="1"/>
- <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
- <Setter Property="HorizontalContentAlignment" Value="Center"/>
- <Setter Property="VerticalContentAlignment" Value="Center"/>
- <Setter Property="Padding" Value="1"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border x:Name="border" Width="36" Height="36" Background="#FF373737" CornerRadius="18" BorderBrush="White" BorderThickness="1" SnapsToDevicePixels="True">
- <Path Data="M11,11 L24,24 M24,11 L11,24" Fill="White" x:Name="path" HorizontalAlignment="Center" Height="14" Stretch="Fill" Stroke="White" VerticalAlignment="Center" Width="14"/>
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True" SourceName="border">
- <Setter Property="Background" TargetName="border" Value="#FFB90F0F"/>
- <Setter Property="BorderBrush" TargetName="border" Value="White"/>
- </Trigger>
- </ControlTemplate.Triggers>
- <!--<Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" RenderDefaulted="{TemplateBinding IsDefaulted}" SnapsToDevicePixels="true">
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
- </Themes:ButtonChrome>-->
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>

Checkbox样式

- <Style x:Key="CheckBoxStyle1" TargetType="{x:Type CheckBox}">
- <Setter Property="OverridesDefaultStyle" Value="True"/>
- <Setter Property="SnapsToDevicePixels" Value="True"/>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type CheckBox}">
- <BulletDecorator FlowDirection="LeftToRight" VerticalAlignment="Center">
- <BulletDecorator.Bullet>
- <Border x:Name="bd"
- BorderThickness="1"
- BorderBrush="#B2B2B2"
- MinHeight="13"
- MinWidth="13"
- VerticalAlignment="Center" Background="White">
- <Path x:Name="cp" Width="12" Height="12"
- Stroke="#4892E7"
- StrokeThickness="2"/>
- </Border>
- </BulletDecorator.Bullet>
- <TextBlock x:Name="textBlock" Margin="2,0" Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="Microsoft YaHei UI" FontSize="13.333"></TextBlock>
- </BulletDecorator>
- <!--
- 控件触发器
- -->
- <ControlTemplate.Triggers>
- <Trigger Property="IsChecked" Value="True">
- <!-- 画上一个勾 -->
- <Setter TargetName="cp" Property="Data"
- Value="M 2,6 L 5,9 11,2"/>
- <Setter Property="Foreground" TargetName="textBlock" Value="#FFE60E0E"/>
- </Trigger>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="bd" Property="BorderBrush" Value="#1583DD">
- </Setter>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- <CheckBox Content="记住密码" Panel.ZIndex="1" Width="80" Height="20" Grid.Row="7" Grid.Column="0" x:Name="IsRememberUserMMBox" Grid.ColumnSpan="2" HorizontalAlignment="Left" Margin="55,0,0,0" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Style="{DynamicResource CheckBoxStyle1}" Foreground="Gray" />

输入账号和密码提示框

- <TextBox Grid.Row="3" Grid.Column="1" Margin="5,4,0,6" BorderBrush="Transparent" BorderThickness="0" VerticalContentAlignment="Center" Text="" FontSize="16">
- <TextBox.Style>
- <Style TargetType="TextBox">
- <Style.Triggers>
- <Trigger Property="Text" Value="{x:Null}">
- <Setter Property="Background" >
- <Setter.Value>
- <VisualBrush Stretch="None">
- <VisualBrush.Visual>
- <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入用户名"/>
- </VisualBrush.Visual>
- </VisualBrush>
- </Setter.Value>
- </Setter>
- </Trigger>
- <Trigger Property="Text" Value="">
- <Setter Property="Background" >
- <Setter.Value>
- <VisualBrush Stretch="None">
- <VisualBrush.Visual>
- <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入用户名"/>
- </VisualBrush.Visual>
- </VisualBrush>
- </Setter.Value>
- </Setter>
- </Trigger>
- </Style.Triggers>
- </Style>
- </TextBox.Style>
- </TextBox>
- <PasswordBox Grid.Row="5" Grid.Column="1" x:Name="pbUserPassWord" BorderBrush="Transparent" BorderThickness="0" Margin="5,4,0,6" Password="" VerticalContentAlignment="Center" FontSize="16" PasswordChanged="pbUserPassWord_PasswordChanged">
- <PasswordBox.Style>
- <Style TargetType="PasswordBox">
- <Style.Triggers>
- <Trigger Property="Tag" Value="{x:Null}">
- <Setter Property="Background" >
- <Setter.Value>
- <VisualBrush Stretch="None">
- <VisualBrush.Visual>
- <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入密码"/>
- </VisualBrush.Visual>
- </VisualBrush>
- </Setter.Value>
- </Setter>
- </Trigger>
- <Trigger Property="Tag" Value="">
- <Setter Property="Background" >
- <Setter.Value>
- <VisualBrush Stretch="None">
- <VisualBrush.Visual>
- <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入密码"/>
- </VisualBrush.Visual>
- </VisualBrush>
- </Setter.Value>
- </Setter>
- </Trigger>
- </Style.Triggers>
- </Style>
- </PasswordBox.Style>
- </PasswordBox>

记录一些WPF常用样式方便以后复用(二)(Button、CheckBox、输入账号密码框)(转)的更多相关文章
- 记录一些WPF常用样式方便以后复用(转)
TextBox文本框 <Style x:Key="TextBoxStyle1" BasedOn="{x:Null}" TargetType="{ ...
- Android 基础一 TextView,Style样式,Activity 传值,选择CheckBox 显示密码
1.修改TextView字体 mTextView = (TextView) findViewById(R.id.textview1); mTextView.setText("I am her ...
- WPF常用样式总结
常用控件样式: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation ...
- WPF 常用样式
TextBox <Window x:Class="WpfDemo.ListBoxTemaple" xmlns="http://schemas.microsoft.c ...
- 记录:asp.net mvc 中 使用 jquery 实现html5 实现placeholder 密码框 提示兼容password IE6
@{ViewBag.Title = "完美结合";} <script>var G_start_time = new Date;</script> <! ...
- checkbox复选框样式
随着现代浏览器的流行,纯CSS设置checkbox也变的很是实用,下面会讲到5种与众不同的checkbox复选框. 首先,需要添加一段CSS隐藏所有的Checkbox复选框,下面我们会改变它的外观.要 ...
- 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇一:WPF常用知识以及本项目设计总结
篇一:WPF常用知识以及本项目设计总结:http://www.cnblogs.com/baiboy/p/wpf.html 篇二:基于OneNote难点突破和批量识别:http://www.cnblog ...
- WPF常用控件应用demo
WPF常用控件应用demo 一.Demo 1.Demo截图如下: 2.demo实现过程 总体布局:因放大缩小窗体,控件很根据空间是否足够改变布局,故用WrapPanel布局. <ScrollVi ...
- WPF中样式和行为和触发器
原文:WPF中样式和行为和触发器 样式简介:样式(style)是组织和重用格式化选项的重要工具,不是使用重复的标记填充XAML,以便设置外边距.内边距.颜色以及字体等细节.而是创建一系列封装所有这些细 ...
随机推荐
- Android-----代码实现打开手机第三方应用APP
最近做一个项目,有一个需要启动第三方应用,和微信的地图查看差不多,需要启动高德,百度或腾讯地图来查看:特来分享,希望有所帮助. 案例效果如图: 要想启动第三方:首先要知道他的包名 一:高德 高德:co ...
- 第一阶段考试:实战Linux系统日常管理
1. [项目名称] 实战Linux系统日常管理 [项目说明] 1.安装部署rhel系统,组建RAID磁盘阵列. 2.安装nginx 通过脚本编写 nginx服务服务启动脚本 [项目考核技能点] 1.安 ...
- 【转】c++析构函数(Destructor)
创建对象时系统会自动调用构造函数进行初始化工作,同样,销毁对象时系统也会自动调用一个函数来进行清理工作,例如释放分配的内存.关闭打开的文件等,这个函数就是析构函数. 析构函数(Destructor)也 ...
- 【Error】 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
mysql 登录输入密码有时会碰到如题的错误. 错误描述: Error 1045 (28000): Access denied for user 'root'@'localhost' (using p ...
- Sum All Numbers in a Range
我们会传递给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. 最小的数字并非总在最前面. 这是一些对你有帮助的资源: Math.max() Math.min() Array.reduc ...
- DB2 设置最大连接数
db2 connect to dbname user username using passwd db2 update db cfg using MAXAPPLS number 查看最大连接数 查看D ...
- js自定义对象.属性 笔记
<一> js自定义对象 一,概述 在Java语言中,我们可以定义自己的类,并根据这些类创建对象来使用,在Javascript中,我们也可以定义自己的类,例如定义User类.Hashtabl ...
- tornado源码分析系列一
先来看一个简单的示例: #!/usr/bin/env python #coding:utf8 import socket def run(): sock = socket.socket(socket. ...
- mac下解决mysql乱码问题
问题描述:在window平台下面数据库插入.已经查找都是很正常的,但是到mac下面查找.插入就不正常了,之后感觉是mysql的问题然后网上搜索学习了下,果然是mysql的问题.解决方案:首先你要先去看 ...
- 利用Appium Python测试爱壁纸的登录和设置壁纸
设置壁纸: #coding:utf-8 #Import the common package import os import unittest from appium import webdrive ...