INPC & RaizePropertyChanged in mvvmlight

In WPF app, MvvM Framework, we binding the UIElement from View to the Public Properties in ViewModel. what does the RaizePropertyChenged do while modifying the Public Properties.

RaizePropertiesChenged("") VS RaizeProertiesChanged("PropertiesName")

  1. According to MSDN,if we set the parameters as null or Empty, it indicate all properties on the object have changed. so, it means all the uielement binding to this object will reflesh. if we provide the propertyName, it will indicate only the target propetyName modificated, So, only uielement binding to this properties reflesh.

  2. when does the uielement reflesh? it will finish the refleshment when the RaizePropertyChanged finished. So, how does the sequences of the refleshing? which uielement will update? here, we base on the ParameterName, Firstly, the uielement directly binding to the Properties will reflesh.

  3. Be careful when we call RaizePropertyChanged() with empty or null paramter. Here is a sample

xaml:

<ComboBox ItemsSource="{Binding CustomerSpace.Customers, Source={StaticResource Locator}, Converter={StaticResource CustomersConverter}}" SelectedItem="{Binding SelectedCustomer ,Converter={StaticResource SelectedCustomerConverter}}"/>

<ComboBox ItemsSource="{Binding SelectedCustomer.Contacts , Converter={StaticResource ContactsConverter}}" SelectedItem="{Binding SelectedContact,Converter={StaticResource SelectedContactConverter}}"/>

cs:

 public Customer SelectedCustomer
{
get
{
return _SelectedCustomer;
}
set
{
_SelectedCustomer = value;
RaisePropertyChanged("");
}
} public Contact SelectedContact
{
get
{
return _SelectedContact;
}
set
{
_SelectedContact = value;
RaisePropertyChanged("");
}
}

In the SelectedContact, when we selected a contact from the contacts combobox, it will Set SelectedContact, then RaizePropertyChanged(""), it will notify all the uielement to reflesh uielement, the SelectedCustomer will update, => the Contacts of combobox will update, => then the SelectedContact will also update => it will call RaisePropertyChanged("") again, then here a loop here.


Summary about the uielement reflesh.

if the PropertyChanged event raized, all the uielement binding to this Property or to the subProperty of the Property, Be Noted about this, the reflesh process will recurse until all the uielement completing the reflesh.

INPC & RaizePropertyChanged in mvvmlight的更多相关文章

  1. UWP开发之Mvvmlight实践九:基于MVVM的项目架构分享

    在前几章介绍了不少MVVM以及Mvvmlight实例,那实际企业开发中将以那种架构开发比较好?怎样分层开发才能节省成本? 本文特别分享实际企业项目开发中使用过的项目架构,欢迎参照使用!有不好的地方欢迎 ...

  2. UWP开发之Mvvmlight实践八:为什么事件注销处理要写在OnNavigatingFrom中

    前一段开发UWP应用的时候因为系统返回按钮事件(SystemNavigationManager.GetForCurrentView().BackRequested)浪费了不少时间.现象就是在手机版的详 ...

  3. UWP开发之Mvvmlight实践七:如何查找设备(Mobile模拟器、实体手机、PC)中应用的Log等文件

    在开发中或者后期测试乃至最后交付使用的时候,如果应用出问题了我们一般的做法就是查看Log文件.上章也提到了查看Log文件,这章重点讲解下如何查看Log文件?如何找到我们需要的Packages安装包目录 ...

  4. [原创]MvvmLight中用IDialogService替代DialogMessage的用法

    在新版的MvvmLight中,DialogMessage被标注为已过时,需要用IDialogService来替代,IDialogService的具体用法如下: 先在主窗体中实现IDialogServi ...

  5. UWP开发之Mvvmlight实践二:Mvvmlight的核心框架MVVM与MVC、MVP的区别(图文详解)

    最近UWP开发在海外很潮流,随着微软收购Xamarin,我们这些C#程序员也可以靠这杆小米枪挑战Android,IOS平台了. 那我们为什么选择MVVM做UWP开发?MVC,MVP,MVVM他们之间到 ...

  6. UWP开发之Mvvmlight实践一:如何在项目中添加使用Mvvmlight(图文详解)

    最近一直在做UWP开发,为了节省成本等等接触到MVVMlight,觉得有必要发点时间研究它的用法与实现原理才行.如果有问题的地方或者有好的建议欢迎提出来. 随着移动开发的热门,Mvvmlight在An ...

  7. MvvmLight ToolKit .Net4.5版本 CanExecute不能刷新界面bug

    一 问题重现    1.在使用最新版本v5.1的MvvmLight中(其实这个问题很早就有了),发现CanExecute不能很好地工作了.一个简单的工程,只有MainWindow和MainWindow ...

  8. 【MVVMLight小记】二.开发一个简单图表生成程序附源码

    上一篇文章介绍了怎样快速搭建一个基于MVVMLight的程序http://www.cnblogs.com/whosedream/p/mvvmlight1.html算是简单入门了下,今天我们来做一个稍许 ...

  9. 【MVVMLight小记】一.快速搭建一个基于MVVMLight的silverlight小程序

    写了篇MVVM小记http://www.cnblogs.com/whosedream/p/mvvmnote1.html,说好要写点MVVMLight的东西,所以接着写,以便和大家共勉. 我假设你已经有 ...

随机推荐

  1. 嵌入在C++程序中的extern "C"

    1.extern的作用 extern是C/C++语言中表明函数和全局变量作用范围(可见性)的关键字,可以告知编译器,用extern声明的函数和变量可以在本模块或其它模块中使用. 通常,在模块的头文件中 ...

  2. .NET平台下,关于数据持久层框架

    在.NET平台下,关于数据持久层框架非常多,本文主要对如下几种做简要的介绍并推荐一些学习的资源: 1.NHibernate 2.NBear 3.Castle ActiveRecord 4.iBATIS ...

  3. Handler 取不到session 解决办法

      Handler需要继承 Handler : IHttpHandler, IReadOnlySessionState, IRequiresSessionState

  4. ListCtrl接受拖动文件

    [引言] 拖放操作在电脑中很常用,例如我们经常复制文件就可以按住ctrl键不放,然后再拖到另外一个窗口中,或者,可以把一个WORD文档直接拖动到WORD窗口即可打开,以前我使用过VB,里面直接有Ole ...

  5. Muzei Live Wallpaper壁纸应用安卓源码项目

    这个刚刚在安卓教程网那里看到的,这个是Muzei Live Wallpaper壁纸应用源码,这是已经在Playstore上线了的android壁纸应用,点击壁纸界面可以磨砂透明效果以及一般背景效果之间 ...

  6. Android开发教程大全介绍

    Android是由谷歌在2007年推出的一个开放系统平台,主要针对移动设备市场,目前版本为Android 4.0.Android基于Linux,开发者可以使用Java或C/C++开发Android应用 ...

  7. php通过正则从字符串中获取所有图片url地址

    /** * 提取字符串中图片url地址 * @param type $str * @return type */ function getimgs($str) { $reg = '/((http|ht ...

  8. mysql触发器关联表更新

    mysql> create table voteItem -> ( -> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, -> titl ...

  9. 微信开发笔记(一)通过.net如何实现接入微信

    微信公众平台,给个人.企业和组织提供业务服务与用户管理能力的全新服务平台.现在基本上每个地方都可以看到微信存在,动不动就是让你扫一下加下微信. 经常遇到这样情况,“到一家餐馆吃饭,拿了个号,前台服务引 ...

  10. nginx 编译安装

    一.安装nginx时必须先安装相应的编译工具yum -y install gcc gcc-c++ autoconf automakeyum -y install zlib zlib-devel ope ...