WPF Style Setter use a TemplateBinding?
- <Style TargetType="{x:Type local:ImageButton}">
- <Setter Property="HorizontalContentAlignment"
- Value="Center"></Setter>
- <Setter Property="VerticalContentAlignment"
- Value="Center"></Setter>
- <Setter Property="Foreground"
- Value="White"></Setter>
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type local:ImageButton}">
- <Border Background="{TemplateBinding Background}"
- x:Name="border"
- BorderBrush="{TemplateBinding BorderBrush}"
- BorderThickness="{TemplateBinding BorderThickness}">
- <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
- Margin="{TemplateBinding Padding}"
- RecognizesAccessKey="True"
- VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
- FocusVisualStyle="{TemplateBinding FocusVisualStyle}" />
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsEnabled"
- Value="false">
- <Setter Property="Foreground"
- Value="#ADADAD" />
- </Trigger>
- <Trigger Property="IsMouseOver"
- Value="True">
- <Setter Property="Background"
- TargetName="border"
- Value="{Binding MouseOverBackground, RelativeSource={RelativeSource TemplatedParent}}" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- public class ImageButton : Button
- {
- static ImageButton()
- {
- DefaultStyleKeyProperty.OverrideMetadata(typeof(ImageButton), new FrameworkPropertyMetadata(typeof(ImageButton)));
- }
- public Brush MouseOverBackground
- {
- get { return (Brush)GetValue(MouseOverBackgroundProperty); }
- set { SetValue(MouseOverBackgroundProperty, value); }
- }
- // Using a DependencyProperty as the backing store for MyProperty. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty MouseOverBackgroundProperty =
- DependencyProperty.Register("MouseOverBackground", typeof(Brush), typeof(ImageButton), new PropertyMetadata(Brushes.Transparent));
- }
WPF Style Setter use a TemplateBinding?的更多相关文章
- WPF Style和Template
WPF中的Style类似于Web应用程序中的CSS,它是控件的一个属性,属于资源的一种. ControlTemplate和DataTemplate区别: ControlTemplate用于改变控件原来 ...
- Bootstrap WPF Style(二)--Glyphicons 字体图标
介绍 关于Glyphicons字体图标,首先给出友情链接 Glyphicons 这个项目是在Bootstrap WPF Style项目基础上做的,详见http://www.cnblogs.com/ts ...
- WPF Style设置和模板化Template
WPF样式设置和模板化是一套功能(样式,模板,触发器和演示图版),可以为产品设置统一外观.类似于html的css,可以快速的设置一系列属性值到控件. 案例:ButtonStyle 这里创建了一个目标类 ...
- WPF Style
<Application x:Class="WzlyTool.App" xmlns="http://schemas.microsoft.com/winfx/20 ...
- WPF style 换肤
原文地址:http://www.cnblogs.com/DebugLZQ/p/3181040.html 原作者:DebugLZQ UI的风格一致性是应用程序应当关注的重要特性. 1.Creating ...
- Bootstrap WPF Style,Bootstrap风格的WPF样式
简介 GitHub地址:https://github.com/ptddqr/bootstrap-wpf-style 此样式基于bootstrap-3.3.0,样式文件里的源码行数都是指的这个版本.CS ...
- WPF:在ControlTemplate中使用TemplateBinding
A bit on TemplateBinding and how to use it inside a ControlTemplate. Introductio Today I'll try to w ...
- C#工具:Bootstrap WPF Style,Bootstrap风格的WPF样式
简介 GitHub地址:https://github.com/ptddqr/bootstrap-wpf-style 此样式基于bootstrap-3.3.0,样式文件里的源码行数都是指的这个版本.CS ...
- wpf Style也继承(包含内部定义事件)
如何在既定皮肤下为某个style添加内容是我今天碰的问题,皮肤往往是对全局control进行设置的,当然这就无法满足某个个性十足的“另类”了,比如当使用DataGridCheckBoxColumn时, ...
随机推荐
- Git 初始化全局user.name 和 user.email
git config --global user.name "username" git config --global user.email "email"
- Codeforces Round #533 (Div. 2) C. Ayoub and Lost Array 【dp】
传送门:http://codeforces.com/contest/1105/problem/C C. Ayoub and Lost Array time limit per test 1 secon ...
- (第二场)D Money 【dp\贪心】
题目:https://www.nowcoder.com/acm/contest/140/D 题目描述: White Cloud has built n stores numbered from 1 t ...
- MVC 实现下拉框
MVC动态实现下拉框的方式有很多种,但是方便快捷的却是很少,现在记录一种常用的下拉框实现方式: 1.先看看视图代码是怎么写的 <div class="form-group col-xs ...
- Objective-C中,ARC下的 strong和weak指针原理解释
Objective-C中,ARC下的 strong和weak指针原理解释 提示:本文中所说的"实例变量"即是"成员变量","局部变量"即是& ...
- webservice 从客户端中检测到有潜在危险的 Request.Form 值
webservice中传递xml格式的参数时报错 webservice 从客户端中检测到有潜在危险的 Request.Form 值解决方案: 1.在web.config的system.web节点中添加 ...
- oracle之DQL
一.单表查询 语法:select * from table where 条件 group by 分组 having 过滤分组 order by 排序 --查询平均工资低于2000的部门的最大工资和平均 ...
- 自定义UICollectionViewLayout并添加UIDynamic
大家也可以到这里查看. UICollectionView是iOS6引入的控件,而UIDynamicAnimator是iOS7上新添加的框架.本文主要涵盖3部分: 一是简单概括UICollectionV ...
- eclipse安装tomcat时只有locahost,不显示server name
Eclipseh中无法安装Tomcat,报错信息如下 Cannot create a server using the selected type 原因:以前安装的tomcat目录改变 解决方法: ...
- Xdebug 备注
安装步骤: 查看自己的环境是否已安装 Xdebug ,查看方法:使用phpinfo(),搜索 Xdebug 如果没有 如图: 如果没有:下一步确定你的PHP版本信息: Xdebug下载地址 https ...