Devexpress RaisePropertyChanged
所有的重载设置字段作为参数传递到指定的值,而属性提高INotifyPropertyChanged.PropertyChanged事件。
如果一个字段已经成功地改变,setProperty方法中返回真。一些重载也需要一个回调方法作为参数。调用该回调后场已经改变。
- 手动设置一个基本的私有字段,然后调用的BindableBase.RaisePropertyChanged方法重载之一。
所有RaisePropertyChanged方法重载需要作为输入参数,这些属性提高INotifyPropertyChanged.PropertyChanged事件。
using System;
using System.Collections.Generic;
using System.Linq;
using DevExpress.Xpf.Mvvm; public class BindableObject : BindableBase { //The property's setter below uses the SetProperty method, which does the following:
//1. Changes the underlying private field.
//2. Raises a change notification for the property, whose name is retrieved from the expression: () => StringProperty.
//This is the preferable method for setting a property in most cases, because it provides strong typing.
//The method is slightly slower than passing the property name as a string (see the declaration of StringProperty2).
string stringProperty;
public string StringProperty {
get { return stringProperty; }
set { SetProperty(ref stringProperty, value, () => StringProperty); }
} //The property's setter below uses the SetProperty method, which does the following:
//1. Changes the underlying private field.
//2. Raises a change notification for the property with the specified name.
//This method is slightly faster than the previous variant, but does not provide strong typing.
string stringProperty2;
public string StringProperty2 {
get { return stringProperty2; }
set { SetProperty(ref stringProperty2, value, "StringProperty2"); }
} //The property's setter below uses the SetProperty method, which does the following:
//1. Changes the underlying private field.
//2. Invokes your callback method (OnStringProperty3Changed) if the property has been changed.
//3. Raises a change notification for the property, whose name is retrieved from the expression: () => StringProperty3.
string stringProperty3;
public string StringProperty3 {
get { return stringProperty3; }
set {
SetProperty(ref stringProperty3, value, () => StringProperty3, OnStringProperty3Changed);
//An alternative form:
SetProperty(ref stringProperty3, value, () => StringProperty3, () => OnStringProperty3Changed());
}
}
private void OnStringProperty3Changed() {
} //The property's setter below uses the SetProperty method, which does the following:
//1. Changes the underlying private field.
//2. Raises a change notification for the property, whose name is retrieved from the expression: () => StringProperty4.
//You can write additional code within the "if" statement, which will be executed after the property has changed.
string stringProperty4;
public string StringProperty4 {
get { return stringProperty4; }
set {
if (SetProperty(ref stringProperty4, value, () => StringProperty4)) {
//The SetProperty method returns true if the property has been changed.
///Do “something” after the property has changed.
//...
}
}
} //The following property's setter does the following:
//1. Changes the underlying private field.
//2. Raises a change notification via the RaisePropertyChanged method.
string stringProperty5;
public string StringProperty5 {
get { return stringProperty5; }
set {
if (stringProperty5 == value)
return;
stringProperty5 = value;
RaisePropertyChanged("StringProperty5");
//An alternative form using a lambda expression, which provides strong typing:
RaisePropertyChanged(() => StringProperty5);
//Do “something” after the property has changed.
//...
}
} //The following property's setter changes a property, and raises change notifications for this property and its dependent properties:
//1. Changes the underlying private field (stringProperty6).
//2. Raises change notifications for StringProperty and StringProperty2.
//3. Raises a change notification for StringProperty6.
//This is the preferable variant in most cases, because it features strong typing.
//The method is slightly slower than passing the property name as a string (see the implementation of StringProperty7).
string stringProperty6;
public string StringProperty6 {
get { return stringProperty6; }
set {
SetProperty(ref stringProperty6, value, () => StringProperty6, () => RaisePropertiesChanged(() => StringProperty, () => StringProperty2)); //An alternative form that is easier to read:
if (SetProperty(ref stringProperty6, value, () => StringProperty6)) {
RaisePropertiesChanged(() => StringProperty, () => StringProperty2);
}
}
} //The following property's setter changes the property and raises change notifications for this property and its dependent properties:
//1. Changes the underlying private field (stringProperty7).
//2. Raises a change notification for StringProperty7.
//3. Raises change notifications for StringProperty and StringProperty2.
//This is a quicker alternative to the previous example, but does not provide strong typing.
string stringProperty7;
public string StringProperty7 {
get { return stringProperty7; }
set {
if (SetProperty(ref stringProperty7, value, () => StringProperty7)) {
RaisePropertiesChanged("StringProperty", "StringProperty2");
}
}
}
}
该代码来自官网
Devexpress RaisePropertyChanged的更多相关文章
- Xamarin devexpress Grid
Devexpress 提供了datagrid 控件对于xamarin 进行支持.整个世界美好了,已经无法用语言来形容一个 被列表控件折磨的要死的人看到熟悉的图标时候的激动了.还有一点引用官网的原话: ...
- Devexpress Winform MVVM
归纳总结备忘 Devexpress Winform MVVM Practice 前言 MVVM Devexpress 正文 databindings及 UI Triggers Command 委托Co ...
- DevExpress MVVM<1>
DevExpress MVVM 概念 模型 -定义数据和您的业务逻辑. 视图 -指定UI,包括绑定到ViewModel中的属性和命令的所有可视元素(按钮,标签,编辑器等). ViewModel-连接模 ...
- 在DevExpress程序中使用GridView直接录入数据的时候,增加列表选择的功能
在我上篇随笔<在DevExpress程序中使用Winform分页控件直接录入数据并保存>中介绍了在GridView以及在其封装的分页控件上做数据的直接录入的处理,介绍情况下数据的保存和校验 ...
- DevExpress - 使用 GaugeControl 标尺组件制作抽奖程序 附源码
前不久,公司举办了15周年庆,其中添加了一个抽奖环节,要从在读学员中随机抽取幸运学员,当然,这个任务就分到了我这里. 最后的效果如下,启动有个欢迎页面,数据是来自Excel的,点击开始则上面的学号及姓 ...
- 图解DevExpress RichEditControl富文本的使用,附源码及官方API
9点半了,刚写到1.2. 该回家了,明天继续写完. 大家还需要什么操作,留言说一下,没有的我明天继续加. 好久没有玩DevExpress了,今天下载了一个玩玩,发现竟然更新到14.2.5了..我去 ...
- DevExpress学习系列(控件篇):GridControl的基本应用
一般属性设置 不显示分组框:Gridview->Option View->Show Group Panel=false 单元格不可编辑:gridcontrol -->gridview ...
- 在DevExpress程序中使用Winform分页控件直接录入数据并保存
一般情况下,我们都倾向于使用一个组织比较好的独立界面来录入或者展示相关的数据,这样处理比较规范,也方便显示比较复杂的数据.不过在一些情况下,我们也可能需要直接在GridView表格上直接录入或者修改数 ...
- 在DevExpress程序中使用TeeList控件以及节点查询的处理
在很多情况下,我们需要通过树列表进行数据的展示,如一些有层次关系的数据,通过有层级的展示,能够使用户更加直观查看和管理相关的数据.在一般Winform开发的情况下,可以使用微软的TreeView控件, ...
随机推荐
- Spring Rabbitmq HelloWorld实例
之前的博客和大家分享了Rabbitmq的基本框架,及其工作原理,网址为 < http://www.cnblogs.com/jun-ma/p/4840869.html >.今天呢,想和大家一 ...
- 精简版StringBuilder,提速字符串拼接
编写目的 在频繁的字符串拼接中,为了提升程序的性能,我们往往会用StringBuilder代替String+=String这样的操作; 而我在实际编码中发现,大部分情况下我用到的只是StringBui ...
- C语言 · 2的次幂表示
问题描述 任何一个正整数都可以用2进制表示,例如:137的2进制表示为10001001. 将这种2进制表示写成2的次幂的和的形式,令次幂高的排在前面,可得到如下表达式:137=2^7+2^3+2^0 ...
- Java ServletContextListener用法
ServletContext 被 Servlet 程序用来与 Web 容器通信.例如写日志,转发请求.每一个 Web 应用程序含有一个Context,被Web应用内的各个程序共享.因为Context可 ...
- web应用中使用JavaMail发送邮件
现在很多的网站都提供有用户注册功能, 通常我们注册成功之后就会收到一封来自注册网站的邮件.邮件里面的内容可能包含了我们的注册的用户名和密码以及一个激活账户的超链接等信息.今天我们也来实现一个这样的功能 ...
- TSQL 数据类型转换
转换函数 cast 或 convert 将表达式类型转换成另一个数据类型,如果转换失败,将导致整个事务失败.SQL Server 2012 新增两个转换函数:try_cast 和 try_conver ...
- 收集的React.JS资料
主页 http://facebook.github.io/react/ https://github.com/facebook/react 中文站 http://www.reactjs.cn/ h ...
- Panorama和Pivot的区别
Panorama 1.提供了更丰富的用户体验(建议最多4个Items项) 2.Item可以设置屏幕方向为水平,支持多于一个屏幕的显示 3.可以使用任意大小的背景图片,Panorama会自动地缩放为屏幕 ...
- javascript面向对象系列第一篇——构造函数和原型对象
× 目录 [1]构造函数 [2]原型对象 [3]总结 前面的话 一般地,javascript使用构造函数和原型对象来进行面向对象编程,它们的表现与其他面向对象编程语言中的类相似又不同.本文将详细介绍如 ...
- [备忘] Automatically reset Windows Update components
这两天遇到Windows 10的更新问题,官方有一个小工具,可以用来修复Windows Update的问题,备忘如下 https://support.microsoft.com/en-us/kb/97 ...