• 所有的重载设置字段作为参数传递到指定的值,而属性提高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的更多相关文章

  1. Xamarin devexpress Grid

    Devexpress 提供了datagrid 控件对于xamarin 进行支持.整个世界美好了,已经无法用语言来形容一个 被列表控件折磨的要死的人看到熟悉的图标时候的激动了.还有一点引用官网的原话: ...

  2. Devexpress Winform MVVM

    归纳总结备忘 Devexpress Winform MVVM Practice 前言 MVVM Devexpress 正文 databindings及 UI Triggers Command 委托Co ...

  3. DevExpress MVVM<1>

    DevExpress MVVM 概念 模型 -定义数据和您的业务逻辑. 视图 -指定UI,包括绑定到ViewModel中的属性和命令的所有可视元素(按钮,标签,编辑器等). ViewModel-连接模 ...

  4. 在DevExpress程序中使用GridView直接录入数据的时候,增加列表选择的功能

    在我上篇随笔<在DevExpress程序中使用Winform分页控件直接录入数据并保存>中介绍了在GridView以及在其封装的分页控件上做数据的直接录入的处理,介绍情况下数据的保存和校验 ...

  5. DevExpress - 使用 GaugeControl 标尺组件制作抽奖程序 附源码

    前不久,公司举办了15周年庆,其中添加了一个抽奖环节,要从在读学员中随机抽取幸运学员,当然,这个任务就分到了我这里. 最后的效果如下,启动有个欢迎页面,数据是来自Excel的,点击开始则上面的学号及姓 ...

  6. 图解DevExpress RichEditControl富文本的使用,附源码及官方API

    9点半了,刚写到1.2.   该回家了,明天继续写完. 大家还需要什么操作,留言说一下,没有的我明天继续加. 好久没有玩DevExpress了,今天下载了一个玩玩,发现竟然更新到14.2.5了..我去 ...

  7. DevExpress学习系列(控件篇):GridControl的基本应用

    一般属性设置 不显示分组框:Gridview->Option View->Show Group Panel=false 单元格不可编辑:gridcontrol -->gridview ...

  8. 在DevExpress程序中使用Winform分页控件直接录入数据并保存

    一般情况下,我们都倾向于使用一个组织比较好的独立界面来录入或者展示相关的数据,这样处理比较规范,也方便显示比较复杂的数据.不过在一些情况下,我们也可能需要直接在GridView表格上直接录入或者修改数 ...

  9. 在DevExpress程序中使用TeeList控件以及节点查询的处理

    在很多情况下,我们需要通过树列表进行数据的展示,如一些有层次关系的数据,通过有层级的展示,能够使用户更加直观查看和管理相关的数据.在一般Winform开发的情况下,可以使用微软的TreeView控件, ...

随机推荐

  1. Android知识杂记(四)

    1.完整退出activity的设计思路 1.1 封装一个基础activity类 public abstract class RootActivity extends FragmentActivity{ ...

  2. ASP.NET MVC SSO单点登录设计与实现

    实验环境配置 HOST文件配置如下: 127.0.0.1 app.com127.0.0.1 sso.com IIS配置如下: 应用程序池采用.Net Framework 4.0 注意IIS绑定的域名, ...

  3. .NET平台下对C3D文件的读写

    [题外话] 最近实验室要我修改C3D(The 3D Biomechanics Data Standard)文件,虽然从网上找到了一个叫c3d4sharp的类库,这个类库单纯读取C3D文件的话还可以,但 ...

  4. 浅析UPnP协议

    摘要:文章介绍了UPnP结构规范和开发流程,指出:UP nP协议使所有联网的设备实现互联,设备工作不需要传统的驱动程序,便可以实现设备间的 相互控制. 关键词:UPnP协议:开发流程:电子技术:工作 ...

  5. 七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC

    系列文章 七天学会ASP.NET MVC (一)——深入理解ASP.NET MVC 七天学会ASP.NET MVC (二)——ASP.NET MVC 数据传递 七天学会ASP.NET MVC (三)— ...

  6. TODO:小程序的春天你想做什么

    TODO:小程序的春天你想做什么 微信小程序是一种全新的连接用户与服务的方式,它可以在微信内被便捷地获取和传播,同时具有出色的使用体验. 初步了解小程序的特点 导航明确,来去自如 统一稳定, 视觉规范 ...

  7. Fiddler调式使用知多少(一)深入研究

    Fiddler调式使用(一)深入研究 阅读目录 Fiddler的基本概念 如何安装Fiddler 了解下Fiddler用户界面 理解不同图标和颜色的含义 web session的常用的快捷键 了解we ...

  8. 2013 duilib入门简明教程 -- FAQ (19)

        虽然前面的教程几乎把所有的知识点都罗列了,但是有很多问题经常在群里出现,所以这里再次整理一下.     需要注意的是,在下面的问题中,除了加上XML属性外,主窗口必须继承自WindowImpl ...

  9. Eos开发——ajax请求

    function saveData(){ form.validate(); if(form.isValid()==false) return; var persons = grid.getChange ...

  10. 探讨Js的事件的冒泡阶段

    近来看到了一个新的知识点叫Js的事件冒泡,因此决定自己来研究一番. 大家应该都知道,Js中的事件处理分为三个阶段,1:事件的捕获阶段,2:处于目标阶段,3:事件的冒泡阶段.那么什么是事件的捕获和冒泡呢 ...