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中的私 ...
随机推荐
- HDU 1228(字符串处理)
题意是将所给算式求出结果. 用的方法非常麻烦,开始没考虑到零也需要处理,以为遇上零直接跳过即可,知道发现零可以占位,比如 one zero 值为 10 而不是 1…… 代码如下: #include & ...
- Asp.Net Core 新篇章
一. 二. 三. 系列章节 第一节:.Net Core环境的安装和常用指令 第X节:XXXXXXXXXXXXXXXXXXXXXXXXXXXX 第X节:XXXXXXXXXXXXXXXXXXXXXXXXX ...
- mysql—增删改查语句总结
关于MySQL数据库——增删改查语句集锦 一.基本的sql语句 CRUD操作: create 创建(添加) read 读取 update 修改 delete 删除 .添加数据 ,'n001','201 ...
- MYSQL数据库的设计与调优
优化思路: 1.检查数据表结构,改善不完善设计 2.跑一遍主要业务,收集常用的数据库查询SQL 3.分析查询SQL,适当拆分,添加索引等优化查询 4.优化SQL的同时,优化代码逻辑 5.添加本地缓存和 ...
- Groovy里面闭包中变量符号的查找与变量定义的限制
class a { def v1 = "v1 in a" static def v2 = "v2 in a" def v4 = "v4 in a&qu ...
- BZOJ 5093[Lydsy1711月赛]图的价值 线性做法
博主曾更过一篇复杂度为$O( k· \log k)$的多项式做法在这里 惊闻本题有$ O(k)$的神仙做法,说起神仙我就想起了于是就去学习了一波 幂与第二类斯特林数 推导看这里 $$ x^k=\sum ...
- 「JavaScript面向对象编程指南」原型
在 JS 中,函数本身也是一个包含了方法(如apply和call)和属性(如length和constructor)的对象,而prototype也是函数对象的一个属性 function f(){} f. ...
- OAuth 2.0详解
OAuth是一个关于授权(authorization)的开放网络标准,在全世界得到广泛应用,目前的版本是2.0版. 本文对OAuth 2.0的设计思路和运行流程,做一个简明通俗的解释,主要参考材料为R ...
- sublime text3输出窗口中文显示乱码问题解决方案
1 前言 略 2 方案 修改Python3.sublime-build内容为 { "cmd": ["C:/Users/Administrator/AppData/Loca ...
- 三, 练习 python索引 (list和tuple)
(1) 练习 请用索引取出下面list的指定元素: 1, # -*- coding: utf-8 -*- L = [ ['Apple', 'Google', 'Microsoft'], ['Java' ...