Interpreting NotifyCollectionChangedEventArgs zz
If you’ve ever consumed INotifyCollectionChanged.CollectionChanged
, then you’ve run into some inadequate documentation for NotifyCollectionChangedEventArgs
. I’ve added the following information to the MSDN “community extensions” (my first contribution), but others have had problems with the stability of community extensions, so the results of my research and Reflector spelunking are also in this blog entry.
In short, the value of the Action
property determines the validity of other properties in this class. NewItems
and OldItems
are null
when they are invalid; NewStartingIndex
and OldStartingIndex
are -1
when they are invalid.
If Action
is NotifyCollectionChangedAction.Add
, then NewItems
contains the items that were added. In addition, if NewStartingIndex
is not -1
, then it contains the index where the new items were added.
If Action
is NotifyCollectionChangedAction.Remove
, then OldItems
contains the items that were removed. In addition, if OldStartingIndex
is not -1
, then it contains the index where the old items were removed.
If Action
is NotifyCollectionChangedAction.Replace
, then OldItems
contains the replaced items and NewItems
contains the replacement items. In addition, NewStartingIndex
and OldStartingIndex
are equal, and if they are not -1
, then they contain the index where the items were replaced.
If Action
is NotifyCollectionChangedAction.Move
, then NewItems
and OldItems
are logically equivalent (i.e., they are SequenceEqual
, even if they are different instances), and they contain the items that moved. In addition, OldStartingIndex
contains the index where the items were moved from, and NewStartingIndex
contains the index where the items were moved to. A Move
operation is logically treated as a Remove
followed by an Add
, so NewStartingIndex
is interpreted as though the items had already been removed.
If Action
is NotifyCollectionChangedAction.Reset
, then no other properties are valid.
Sources
There are two blog entries that helped me get started: Making Sense of NotifyCollectionChangedEventArgs and An Alternative to ObservableCollection. However, more details were still lacking; fortunately, Reflector saved the day! The primary .NET sources were: [WindowsBase.dll, 3.0.0.0] System.Collections.ObjectModel.ObservableCollection<T>
- SetItem
, RemoveItem
, MoveItem
, etc.; and [PresentationFramework.dll, 3.0.0.0] System.Windows.Data.CollectionView
- ProcessCollectionChanged
, AdjustCurrencyFor*
.
Interpreting NotifyCollectionChangedEventArgs zz的更多相关文章
- 使用FP-Growth算法高效发现频繁项集【zz】
FP树构造 FP Growth算法利用了巧妙的数据结构,大大降低了Aproir挖掘算法的代价,他不需要不断得生成候选项目队列和不断得扫描整个数据库进行比对.为了达到这样的效果,它采用了一种简洁的数据结 ...
- [zz] 基于国家标准的 EndNote 输出样式模板
基于国家标准的 EndNote 输出样式模板 https://cnzhx.net/blog/endnote-output-style-cnzhx/ 发表于 2013-05-26 作者 Haoxian ...
- 炉石ZZ操作 [20161224]
昨天吃完晚饭,开了一盘炉石.选的龙牧,遇到对面马克扎尔战士. 中途,我场上3个较大随从,他突然先拍下一个铜须,菊花一紧,然后果然拍下了大工匠(之前用龙人侦察者看到他牌库有这张牌),逗比的一幕开始了,首 ...
- VC++动态链接库(DLL)编程深入浅出(zz)
VC++动态链接库(DLL)编程深入浅出(zz) 1.概论 先来阐述一下DLL(Dynamic Linkable Library)的概念,你可以简单的把DLL看成一种仓库,它提供给你一些可以直接拿来用 ...
- warning C4305: “=”: 从“int”到“unsigned char”截断解决方法[zz]
在控制台程序中定义: float x; x=22.333; 编译会出现 warning C4305: “初始化”: 从“double”到“float”截断 系统默认此浮点数是22.333是double ...
- 北京市小升初 zz
发信人: django (牛魔王), 信区: SchoolEstate 标 题: 北京市小升初掐尖方式的演变过程(看后恍然大悟) 发信站: 水木社区 (Thu Feb 4 10:51:23 201 ...
- [zz] JIT&HotSpot
zz from 百度百科 最早的Java建置方案是由一套转译程式(interpreter),将每个Java指令都转译成对等的微处理器指令,并根据转译后的指令先后次序依序执行,由于一个Java指令可能被 ...
- [ZZ]计算机视觉、机器学习相关领域论文和源代码大集合
原文地址:[ZZ]计算机视觉.机器学习相关领域论文和源代码大集合作者:计算机视觉与模式 注:下面有project网站的大部分都有paper和相应的code.Code一般是C/C++或者Matlab代码 ...
- 那些证书相关的玩意儿(SSL,X.509,PEM,DER,CRT,CER,KEY,CSR,P12等)[zz]
openssl dgst –sign privatekey.pem –sha1 –keyform PEM –c c:\server.pem 将文件用sha1摘要,并用privatekey.pem中的私 ...
随机推荐
- 实现Map接口(hash原理)
闲来无事,就实现一个简单的map来练练手吧! HashMap的底层实现主要是基于数组和链表来实现的,HashMap中通过key的hashCode来计算hash值的,由这个hash值计算在数组中的位置, ...
- 解决reverse改变原数组
let arr =[1,2,3,4] console.log(arr) //[1,2,3,4] let arr2 = arr; console.log(arr2) //[4,3,2,1] consol ...
- input file 重复上传同一张图片失效的解决办法
解决方法: 每次取消图片预览后,重置input[type=’file’]的value的值 链接:https://blog.csdn.net/zd717822023/article/details/78 ...
- 关于ElementUI中MessageBox弹框的取消键盘触发事件(enter,esc)关闭弹窗(执行事件)的解决方法
好久没见了 在项目中遇到一个小小的需求,总结了一下! 详细我就不介绍了,相信大家用过的话,很了解.详见文档-----------> http://element-cn.eleme.io/#/zh ...
- 出现: object() takes no parameters 之后应该如何修改
这个错误花费了很多的时间去解决,包括重写代码也无济于事. 因为粗心,浪费了很多的时间在这个上面,特写此博客来记录,也希望朋友们不要粗心,特别是初学者. 接下来进入正文: 当在写self.XXX 下方 ...
- Codeforces Round #542 (Div. 1) 题解
开学了住校了打不了深夜场 好难受啊QwQ A 显然对于每个起点,我们只需要贪心记录这个起点出发出去的糖果数量以及离自己最近的糖果 因为这个起点最后一次装载糖果一定是装载终点离自己最近的那个糖果 $ O ...
- LOJ #2978「THUSCH 2017」杜老师
听说LOJ传了THUSC题赶紧上去看一波 随便点了一题都不会做想了好久才会写暴力爆了一发过了... LOJ #2978 题意 $ T$次询问,每次询问$ L,R$,问有多少种选取区间中数的方案使得选出 ...
- 为什么HashMap线程不安全,Hashtable和ConcurrentHashMap线程安全
HashMap源码 public V put(K key, V value) { return putVal(hash(key), key, value, false, true); } final ...
- Spring缓存注解@Cacheable
@Cacheable @Cacheable 的作用 主要针对方法配置,能够根据方法的请求参数对其结果进行缓存 @Cacheable 作用和配置方法 参数 解释 example value 缓存的名称, ...
- Git学习(一):初始化仓库、添加文件、版本回退
目录 Git学习(一):初始化.添加文件.版本回退 初始化一个仓库 添加文件到Git仓库 版本回退 Git学习(一):初始化.添加文件.版本回退 初始化一个仓库 本文使用的命令行工具为cmder,部分 ...