Button (一)

  1. <Style x:Key="ButtonSaveStyle" TargetType="{x:Type Button}">
  2. <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
  3. <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
  4. <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
  5. <Setter Property="BorderThickness" Value="1"/>
  6. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  7. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  8. <Setter Property="VerticalContentAlignment" Value="Center"/>
  9. <Setter Property="Padding" Value="1"/>
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="{x:Type Button}">
  13. <Border x:Name="Chrome" CornerRadius="5" Background="{Binding Background, RelativeSource={RelativeSource TemplatedParent}}" >
  14. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  15. </Border>
  16. <!--<Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" RenderDefaulted="{TemplateBinding IsDefaulted}" SnapsToDevicePixels="true">
  17. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  18. </Themes:ButtonChrome>-->
  19. <ControlTemplate.Triggers>
  20. <Trigger Property="IsMouseOver" Value="True">
  21. <Setter Property="Background" TargetName="Chrome" Value="{Binding BorderBrush, RelativeSource={RelativeSource TemplatedParent}}"/>
  22. </Trigger>
  23. <Trigger Property="IsEnabled" Value="false">
  24. <Setter Property="Foreground" Value="#ADADAD"/>
  25. </Trigger>
  26. </ControlTemplate.Triggers>
  27. </ControlTemplate>
  28. </Setter.Value>
  29. </Setter>
  30. </Style>
  31. <!--Background为背景颜色,BorderBrush为鼠标移入的背景-->
  32. <Button Width="100" Height="35" VerticalAlignment="Top" Background="#FFFD5F4F" BorderBrush="#FFEC685C" Content="保存" Style="{DynamicResource ButtonSaveStyle}" Foreground="White" TextOptions.TextFormattingMode="Display" FontSize="13.333"/>

Button(二)

  1. <Style x:Key="ButtonStyle1" TargetType="{x:Type Button}">
  2. <Setter Property="FocusVisualStyle" Value="{StaticResource ButtonFocusVisual}"/>
  3. <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}"/>
  4. <Setter Property="BorderBrush" Value="{StaticResource ButtonNormalBorder}"/>
  5. <Setter Property="BorderThickness" Value="1"/>
  6. <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
  7. <Setter Property="HorizontalContentAlignment" Value="Center"/>
  8. <Setter Property="VerticalContentAlignment" Value="Center"/>
  9. <Setter Property="Padding" Value="1"/>
  10. <Setter Property="Template">
  11. <Setter.Value>
  12. <ControlTemplate TargetType="{x:Type Button}">
  13. <Border x:Name="border" Width="36" Height="36" Background="#FF373737" CornerRadius="18" BorderBrush="White" BorderThickness="1" SnapsToDevicePixels="True">
  14. <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"/>
  15. </Border>
  16. <ControlTemplate.Triggers>
  17. <Trigger Property="IsMouseOver" Value="True" SourceName="border">
  18. <Setter Property="Background" TargetName="border" Value="#FFB90F0F"/>
  19. <Setter Property="BorderBrush" TargetName="border" Value="White"/>
  20. </Trigger>
  21. </ControlTemplate.Triggers>
  22. <!--<Themes:ButtonChrome x:Name="Chrome" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" RenderMouseOver="{TemplateBinding IsMouseOver}" RenderPressed="{TemplateBinding IsPressed}" RenderDefaulted="{TemplateBinding IsDefaulted}" SnapsToDevicePixels="true">
  23. <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
  24. </Themes:ButtonChrome>-->
  25.  
  26. </ControlTemplate>
  27. </Setter.Value>
  28. </Setter>
  29. </Style>

Checkbox样式

  1. <Style x:Key="CheckBoxStyle1" TargetType="{x:Type CheckBox}">
  2. <Setter Property="OverridesDefaultStyle" Value="True"/>
  3. <Setter Property="SnapsToDevicePixels" Value="True"/>
  4. <Setter Property="Template">
  5. <Setter.Value>
  6. <ControlTemplate TargetType="{x:Type CheckBox}">
  7. <BulletDecorator FlowDirection="LeftToRight" VerticalAlignment="Center">
  8. <BulletDecorator.Bullet>
  9. <Border x:Name="bd"
  10. BorderThickness="1"
  11. BorderBrush="#B2B2B2"
  12. MinHeight="13"
  13. MinWidth="13"
  14. VerticalAlignment="Center" Background="White">
  15. <Path x:Name="cp" Width="12" Height="12"
  16. Stroke="#4892E7"
  17. StrokeThickness="2"/>
  18. </Border>
  19.  
  20. </BulletDecorator.Bullet>
  21. <TextBlock x:Name="textBlock" Margin="2,0" Text="{Binding Content, RelativeSource={RelativeSource TemplatedParent}}" FontFamily="Microsoft YaHei UI" FontSize="13.333"></TextBlock>
  22. </BulletDecorator>
  23. <!--
  24. 控件触发器
  25. -->
  26. <ControlTemplate.Triggers>
  27. <Trigger Property="IsChecked" Value="True">
  28. <!-- 画上一个勾 -->
  29. <Setter TargetName="cp" Property="Data"
  30. Value="M 2,6 L 5,9 11,2"/>
  31. <Setter Property="Foreground" TargetName="textBlock" Value="#FFE60E0E"/>
  32.  
  33. </Trigger>
  34. <Trigger Property="IsMouseOver" Value="True">
  35. <Setter TargetName="bd" Property="BorderBrush" Value="#1583DD">
  36. </Setter>
  37. </Trigger>
  38. </ControlTemplate.Triggers>
  39. </ControlTemplate>
  40. </Setter.Value>
  41. </Setter>
  42. </Style>
  43.  
  44. <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" />

输入账号和密码提示框

  1. <TextBox Grid.Row="3" Grid.Column="1" Margin="5,4,0,6" BorderBrush="Transparent" BorderThickness="0" VerticalContentAlignment="Center" Text="" FontSize="16">
  2. <TextBox.Style>
  3. <Style TargetType="TextBox">
  4. <Style.Triggers>
  5. <Trigger Property="Text" Value="{x:Null}">
  6. <Setter Property="Background" >
  7. <Setter.Value>
  8. <VisualBrush Stretch="None">
  9. <VisualBrush.Visual>
  10. <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入用户名"/>
  11. </VisualBrush.Visual>
  12. </VisualBrush>
  13. </Setter.Value>
  14. </Setter>
  15. </Trigger>
  16. <Trigger Property="Text" Value="">
  17. <Setter Property="Background" >
  18. <Setter.Value>
  19. <VisualBrush Stretch="None">
  20. <VisualBrush.Visual>
  21. <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入用户名"/>
  22. </VisualBrush.Visual>
  23. </VisualBrush>
  24. </Setter.Value>
  25. </Setter>
  26. </Trigger>
  27. </Style.Triggers>
  28. </Style>
  29. </TextBox.Style>
  30.  
  31. </TextBox>
  32. <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">
  33. <PasswordBox.Style>
  34. <Style TargetType="PasswordBox">
  35. <Style.Triggers>
  36. <Trigger Property="Tag" Value="{x:Null}">
  37. <Setter Property="Background" >
  38. <Setter.Value>
  39. <VisualBrush Stretch="None">
  40. <VisualBrush.Visual>
  41. <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入密码"/>
  42. </VisualBrush.Visual>
  43. </VisualBrush>
  44. </Setter.Value>
  45. </Setter>
  46. </Trigger>
  47. <Trigger Property="Tag" Value="">
  48. <Setter Property="Background" >
  49. <Setter.Value>
  50. <VisualBrush Stretch="None">
  51. <VisualBrush.Visual>
  52. <TextBox BorderThickness="0" BorderBrush="Transparent" VerticalContentAlignment="Center" Width="310" Background="#0000" FontSize="13" HorizontalAlignment="Left" Foreground="Gray" Text="请输入密码"/>
  53. </VisualBrush.Visual>
  54. </VisualBrush>
  55. </Setter.Value>
  56. </Setter>
  57. </Trigger>
  58. </Style.Triggers>
  59. </Style>
  60. </PasswordBox.Style>
  61.  
  62. </PasswordBox>

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

  1. 记录一些WPF常用样式方便以后复用(转)

    TextBox文本框 <Style x:Key="TextBoxStyle1" BasedOn="{x:Null}" TargetType="{ ...

  2. Android 基础一 TextView,Style样式,Activity 传值,选择CheckBox 显示密码

    1.修改TextView字体 mTextView = (TextView) findViewById(R.id.textview1); mTextView.setText("I am her ...

  3. WPF常用样式总结

    常用控件样式: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation ...

  4. WPF 常用样式

    TextBox <Window x:Class="WpfDemo.ListBoxTemaple" xmlns="http://schemas.microsoft.c ...

  5. 记录:asp.net mvc 中 使用 jquery 实现html5 实现placeholder 密码框 提示兼容password IE6

    @{ViewBag.Title = "完美结合";} <script>var G_start_time = new Date;</script> <! ...

  6. checkbox复选框样式

    随着现代浏览器的流行,纯CSS设置checkbox也变的很是实用,下面会讲到5种与众不同的checkbox复选框. 首先,需要添加一段CSS隐藏所有的Checkbox复选框,下面我们会改变它的外观.要 ...

  7. 【基于WPF+OneNote+Oracle的中文图片识别系统阶段总结】之篇一:WPF常用知识以及本项目设计总结

    篇一:WPF常用知识以及本项目设计总结:http://www.cnblogs.com/baiboy/p/wpf.html 篇二:基于OneNote难点突破和批量识别:http://www.cnblog ...

  8. WPF常用控件应用demo

    WPF常用控件应用demo 一.Demo 1.Demo截图如下: 2.demo实现过程 总体布局:因放大缩小窗体,控件很根据空间是否足够改变布局,故用WrapPanel布局. <ScrollVi ...

  9. WPF中样式和行为和触发器

    原文:WPF中样式和行为和触发器 样式简介:样式(style)是组织和重用格式化选项的重要工具,不是使用重复的标记填充XAML,以便设置外边距.内边距.颜色以及字体等细节.而是创建一系列封装所有这些细 ...

随机推荐

  1. Android-----代码实现打开手机第三方应用APP

    最近做一个项目,有一个需要启动第三方应用,和微信的地图查看差不多,需要启动高德,百度或腾讯地图来查看:特来分享,希望有所帮助. 案例效果如图: 要想启动第三方:首先要知道他的包名 一:高德 高德:co ...

  2. 第一阶段考试:实战Linux系统日常管理

    1. [项目名称] 实战Linux系统日常管理 [项目说明] 1.安装部署rhel系统,组建RAID磁盘阵列. 2.安装nginx 通过脚本编写 nginx服务服务启动脚本 [项目考核技能点] 1.安 ...

  3. 【转】c++析构函数(Destructor)

    创建对象时系统会自动调用构造函数进行初始化工作,同样,销毁对象时系统也会自动调用一个函数来进行清理工作,例如释放分配的内存.关闭打开的文件等,这个函数就是析构函数. 析构函数(Destructor)也 ...

  4. 【Error】 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

    mysql 登录输入密码有时会碰到如题的错误. 错误描述: Error 1045 (28000): Access denied for user 'root'@'localhost' (using p ...

  5. Sum All Numbers in a Range

    我们会传递给你一个包含两个数字的数组.返回这两个数字和它们之间所有数字的和. 最小的数字并非总在最前面. 这是一些对你有帮助的资源: Math.max() Math.min() Array.reduc ...

  6. DB2 设置最大连接数

    db2 connect to dbname user username using passwd db2 update db cfg using MAXAPPLS number 查看最大连接数 查看D ...

  7. js自定义对象.属性 笔记

    <一> js自定义对象 一,概述 在Java语言中,我们可以定义自己的类,并根据这些类创建对象来使用,在Javascript中,我们也可以定义自己的类,例如定义User类.Hashtabl ...

  8. tornado源码分析系列一

    先来看一个简单的示例: #!/usr/bin/env python #coding:utf8 import socket def run(): sock = socket.socket(socket. ...

  9. mac下解决mysql乱码问题

    问题描述:在window平台下面数据库插入.已经查找都是很正常的,但是到mac下面查找.插入就不正常了,之后感觉是mysql的问题然后网上搜索学习了下,果然是mysql的问题.解决方案:首先你要先去看 ...

  10. 利用Appium Python测试爱壁纸的登录和设置壁纸

    设置壁纸: #coding:utf-8 #Import the common package import os import unittest from appium import webdrive ...