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控件, ...
随机推荐
- 初识WEB:输入URL之后的故事
1. 概述2. HTTP请求过程3. 相关性能检测及优化手段4. 浏览器的呈现过程5. 浏览器的呈现引擎6. 引用及延伸阅读 概述 为什么输入www.cnblogs.com之后敲一个回车,浏览器就会显 ...
- HTML和CSS经典布局6
如下图: 需求: 1. 如图 2. 可以从任意div标签开始. <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xh ...
- Hadoop学习笔记—20.网站日志分析项目案例(二)数据清洗
网站日志分析项目案例(一)项目介绍:http://www.cnblogs.com/edisonchou/p/4449082.html 网站日志分析项目案例(二)数据清洗:当前页面 网站日志分析项目案例 ...
- Javascript模拟继承(赠送.net吐槽一段)
首先吐槽一句,今年的就业形势很不乐观啊,特别是搞.net的(相对java),特特别是还没出校门没有正式工作经验的,找个实习很难,前些天接了个面试电话,上来就质疑我“你一个在校大学生怎么可能做了那么多项 ...
- Opengl中矩阵和perspective/ortho的相互转换
Opengl中矩阵和perspective/ortho的相互转换 定义矩阵 Opengl变换需要用四维矩阵.我们来定义这样的矩阵. +BIT祝威+悄悄在此留下版了个权的信息说: 四维向量 首先,我们定 ...
- 通过扩展让ASP.NET Web API支持W3C的CORS规范
让ASP.NET Web API支持JSONP和W3C的CORS规范是解决"跨域资源共享"的两种途径,在<通过扩展让ASP.NET Web API支持JSONP>中我们 ...
- Elasticsearch5.0 安装问题集锦
使用Elasticsearch5.0 必须安装jdk1.8 [elsearch@vm-mysteel-dc-search01 bin]$ java -version java version &quo ...
- Spill data to tempdb
查看Execution Plan时,在Sort Operator上,发现一个Warning:Operator used tempdb to spill data during execution wi ...
- Dnsmasq安装与配置
默认的情况下,我们平时上网用的本地DNS服务器都是使用电信或者联通的,但是这样也导致了不少的问题,首当其冲的就是上网时经常莫名地弹出广告,或者莫名的流量被消耗掉导致网速变慢.其次是部分网站域名不能正常 ...
- 应用程序框架实战二十九:Util Demo介绍
上文介绍了我选择EasyUi作为前端框架的原因,并发放了最新Demo.本文将对这个Demo进行一些介绍,以方便你能够顺利运行起来. 这个Demo运行起来以后,是EasyUi的一个简单CRUD操作,数据 ...