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++断言与静态断言

    断言是很早之前就有的东西了,只需要引入cassert头文件即可使用.往往assert被用于检查不可能发生的行为,来确保开发者在调试阶段尽早发现“不可能”事件真的发生了,如果真的发生了,那么就表示代码的 ...

  2. ASP.NET MVC学习1

    ViewBag是一个dynamic(动态类型)类型集合,可以动态添加任何类型的任意名称的属性和值,ViewBag是Controller和view之间传递数据的,如以下: ViewBag.HtmlStr ...

  3. centOS 6.4下安装中文输入法

    1.用root登录 ,或su root 2.yum install "@Chinese Support" 3.exit 4.回到桌面,system->preferences- ...

  4. Android IOS WebRTC 音视频开发总结(四四)-- webrtc图书

    本文主要介绍即将出版的webrtc图书相关信息,支持原创,转载必须说明出处,更多详见www.rtc.help --------------------------------------------- ...

  5. State

    #include <iostream> using namespace std; #define DESTROY_POINTER(ptr) if (ptr) { delete ptr; p ...

  6. ie8以下不兼容document.getElementsByName解决方法

    在IE8以认为只有文本标签才有name属性的,一些元素标签用document.getElementsByName获取不到DOM,如DIV,span等,这里做一下兼容. HTML: <div na ...

  7. static local variable

    Putting the keyword static in front of a local variable declaration creates a special type of variab ...

  8. 深入浅出MongoDB(二)概述

    上次的博文深入浅出MongoDB(一)NoSQL中我们已经简单介绍了一下NoSQL的基本概念,这次我们来了解一下MongoDB的相关概念. 1.简介 MongoDB是一款由C++编写的高性能.开源.无 ...

  9. Mysql varchar大小长度问题介绍

    如果被 varchar 超过上述的 b 规则,被强转成 text 类型,则每个字段占用定义长度为 11 字节,当然这已经不是 varchar 了4.0版本以下,varchar(20),指的是20字节, ...

  10. Android Socket通信

    1.TCP: xml: <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns: ...