WPF 精修篇 属性触发器】的更多相关文章

原文:WPF 精修篇 属性触发器 属性触发器是通过  某个条件触发改变属性 通过无代码实现功能 <Style TargetType="{x:Type Label}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="FontSize" Value="30"…
原文:WPF精修篇 多数据触发器 有多属性触发器 就有多数据触发器 <Grid> <CheckBox x:Name="c1" Content="许可协议1" HorizontalAlignment="Left" Margin="151,157,0,0" VerticalAlignment="Top"/> <CheckBox x:Name="c2" Conte…
原文:WPF 精修篇 数据触发器 数据触发器 可以使用Binding 来绑定控件 或者数据源 来触发相关动作 举栗子 <Window.Resources> <Style TargetType="{x:Type Label}"> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=red,Path=IsChecked}" Value="True&qu…
原文:WPF 精修篇 属性动画 属性动画 是通过 Storyboard 来改变属性值 <Rectangle x:Name="rect" Width="200" Height="200" > <Rectangle.Fill> <SolidColorBrush Color="Beige" x:Name="color"></SolidColorBrush> <…
原文:WPF 精修篇 事件触发器 事件触发器 一般使用的就是动画 <Grid> <TextBlock Text="事件触发器" Opacity="0.2" FontSize="30" HorizontalAlignment="Center" VerticalAlignment="Center"> <TextBlock.Style> <Style TargetType…
原文:WPF 精修篇 多属性触发器 多属性触发器就是多个属性都满足在触发 在属性触发器上加了一些逻辑判断 举栗子 这个栗子里  textBox 要满足俩个条件 才能触发背景变色 1)textbox的 IsEnabled 为true 2) Texbox获得焦点 <Window.Resources> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <MultiTrigger> &l…
原文:WPF 精修篇 依赖属性 依赖属性使用场景 1. 希望可在样式中设置属性. 2. 希望属性支持数据绑定. 3. 希望可使用动态资源引用设置属性. 4. 希望从元素树中的父元素自动继承属性值. 5. 希望属性可进行动画处理. 6. 希望属性系统在属性系统.环境或用户执行的操作或者读取并使用样式更改了属性以前的值时报告. 7. 希望使用已建立的.WPF 进程也使用的元数据约定,例如报告更改属性值时是否要求布局系统重新编写元素的可视化对象. 依赖属性生成 PropertyMetadata 后面可…
原文:WPF 精修篇 用户控件 增加用户控件 数据绑定还是用依赖属性 使用的事件 就委托注册一下 public delegate void ButtonClick(object b,EventArgs e); public event ButtonClick OnColorsClick ; private void Button_Click(object sender, RoutedEventArgs e) { if (OnColorsClick != null) { OnColorsClick…
原文:WPF 精修篇 数据绑定到对象 数据绑定到对象 首先 我们需要一个对象 public class Preson { private string name; public string Name { get { return name; } set { name = value; } } private string address; public string Address { get { return address; } set { address = value; } } pri…
原文:WPF 精修篇 数据绑定 更新通知 开始更新一点有意思的了 首先 数据绑定  其中之一 Element 绑定 看例子 <Window x:Class="WpfApplication20.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml…