You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If INotifyCollectionChanged.CollectionChanged -> NotifyCollectionChangedEventArgs.NewItems has more than one item, most WPF controls will throw an exception.
The main reason for this original design is that ObservableCollection doesn't have an AddRange method and the controls assum that nothing else will support INotifyCollectionChanged.
Reacted by Morten Nielsen, Adam Caviness, Haraszti Gábor, Nikita Tsukanov, Ryouko Konpaku, Roman Bukin, Mokeev Andrey, Joe Amenta, Nico Rieck, Patrick Kranz and 69 more
Yes! This has been extremely annoying. Being able to trigger one large change for a set of items without causing UI relayout over and over again would be a huge perf improvement. The interface completely supports this, but for some reason WPF never has. Currently our only choice is to trigger a reset event, which causes a complete relayout of all items.
Reacted by Bastian Schmidt, Joe Amenta, Kevin, Shmueli Englard, Nicholas Genco, Ryouko Konpaku, Artyom V. Gorchakov, Alexander Johnston, BradleyUffner, Matvei Stefarov and 3 more
publicpartialclassCollection<T>{publicvoidAddRange(IEnumerable<T>collection);publicvoidInsertRange(intindex,IEnumerable<T>collection);publicvoidRemoveRange(intindex,intcount);publicvoidReplaceRange(intindex,intcount,IEnumerable<T>collection);// These are override by ObservableCollection<T> to raise the event:protectedvirtualvoidInsertItemsRange(intindex,IEnumerable<T>collection);protectedvirtualvoidRemoveItemsRange(intindex,intcount);protectedvirtualvoidReplaceItemsRange(intindex,intcount,IEnumerable<T>collection);}
Reacted by Viacheslav Ivanov, JesperTreetop, James Montemagno, Max Katz, andreykaone, Ryouko Konpaku, Yupei Liu, Alexander Johnston, Roland Pheasant, Andreas Müller and 11 more
The main reason for this original design is that ObservableCollection doesn't have an AddRange method
This isn't about ObservableCollection, but about INotifyCollectionChanged interface. Any collection can implement that interface and have add-range, or be adding items in "chunks" (like incrementally loading datasources etc)
I was under the impression that it's "just" System.Windows.Data.CollectionView which would need to change, and that (in theory) something else could implement System.ComponentModel.ICollectionView to get the desired benefits.
Admittedly, however, I haven't tried it... am I mistaken?
Edit: that said, System.ComponentModel.ICollectionView itself extends System.Collections.Specialized.INotifyCollectionChanged, which makes me think that System.Windows.Data.CollectionView is likely to be just the most visible of, perhaps, many places that don't support batched changes...
In this context, I would like to point out the following problem: dotnet/efcore#12675
EF core uses ObservableHashSet that implements INotifyCollectionChanged. However, the ObservableHashSet is an unsorted collection and is not able to specify an index in the OldStartingIndex property for a Remove action. This leads to an exception at this point in the EnumerableCollectionView.cs:
Suggestion: We don't we log an issue for each control that have a problem with multi-item changes, and that way we can start chipping away at it and hopefully get to a point where we can add AddRange to ObservableCollection<T> ? This issue could then be the epic for the individual tasks.
Reacted by Thomas Levesque, rampaa and Energy
Reacted by Edward Miller, Patrick Kranz and rampaa
Activity
dotMorten commentedon Dec 4, 2018
Yes! This has been extremely annoying. Being able to trigger one large change for a set of items without causing UI relayout over and over again would be a huge perf improvement. The interface completely supports this, but for some reason WPF never has. Currently our only choice is to trigger a reset event, which causes a complete relayout of all items.
benaadams commentedon Dec 4, 2018
The following apis have been approved for
Collection<T>andObservableCollection<T>in .NET Core; though not implemented yet https://github.com/dotnet/corefx/issues/10752:dotMorten commentedon Dec 4, 2018
This isn't about ObservableCollection, but about INotifyCollectionChanged interface. Any collection can implement that interface and have add-range, or be adding items in "chunks" (like incrementally loading datasources etc)
airbreather commentedon Dec 4, 2018
I was under the impression that it's "just"
System.Windows.Data.CollectionViewwhich would need to change, and that (in theory) something else could implementSystem.ComponentModel.ICollectionViewto get the desired benefits.Admittedly, however, I haven't tried it... am I mistaken?
Edit: that said,
System.ComponentModel.ICollectionViewitself extendsSystem.Collections.Specialized.INotifyCollectionChanged, which makes me think thatSystem.Windows.Data.CollectionViewis likely to be just the most visible of, perhaps, many places that don't support batched changes...YZahringer commentedon Apr 18, 2021
Could be a 6.0.0 candidate? This currently blocks the range support in .net 6 ObservableCollection
DamirLisak commentedon Aug 16, 2023
In this context, I would like to point out the following problem:
dotnet/efcore#12675
EF core uses ObservableHashSet that implements INotifyCollectionChanged. However, the ObservableHashSet is an unsorted collection and is not able to specify an index in the OldStartingIndex property for a Remove action. This leads to an exception at this point in the EnumerableCollectionView.cs:
wpf/src/Microsoft.DotNet.Wpf/src/PresentationFramework/MS/Internal/Data/EnumerableCollectionView.cs
Line 423 in 026f338
In this case, the entire CollectionView would have to be reloaded.
symbiogenesis commentedon Jan 26, 2024
This is one of the top-requested features in all of the world of .NET, going back many years. Offering this is crucial.
dotMorten commentedon Jul 5, 2024
Suggestion: We don't we log an issue for each control that have a problem with multi-item changes, and that way we can start chipping away at it and hopefully get to a point where we can add
AddRangetoObservableCollection<T>? This issue could then be the epic for the individual tasks.symbiogenesis commentedon Jul 8, 2024
@anjali-wpf @singhashish-wpf
symbiogenesis commentedon Jul 8, 2024
@robertmclaws
docs(dotnet#52): 波dotnet#52 前半段登记 —— 新增 D-G100(SetWindowPos(NOSIZE|NO…
17 remaining items
revert(dotnet#52): 还原被 git add -A 夹带进 37def7e 的 W131A 在办 native 源至 do…
docs(dotnet#52): W127A 报告 §⑪ 发布完整性事件(git add -A 夹带 → 还原发布态)
docs(dotnet#52): W129A 登记批(一)—— 新登记 D-G108(git add -A 夹带别车道在办件进发布)/D-…
docs(dotnet#52): W129A 报告 —— 登记批(一)读数与推送(D-G108/D-G109/TASK-0209/TASK…
docs(dotnet#52): W129A 报告 RECORD-补 —— 第 2/3 笔推送读数 + BYTECHECK ok=4 + …
docs(dotnet#52): W129A 报告 —— 两处表述精度修正(节标题计数口径、报告自身 sha 自指口径)+ 自洽 sha1…
docs(dotnet#52): W129A 报告 RECORD-补 2 —— 推送后复测(含别家 dotnet#53 在办件 verif…
docs(dotnet#52): TASK-0203 终报收口 ✅(175/175 有效、2 命中同址 0x7fff740dcdf3、上界…
docs(dotnet#52): W130A 报告 RECORD-补(推送后 head/BYTECHECK/自 sha16;仅报告自身)
docs(dotnet#52): 补推 W128A/W118A 两份证据报告(占位符门 0 命中)+ ROUTES.md §15q(远程 …
docs(dotnet#52): WC01 报告 —— 补推两报告 + §15q(DECLDRIFT=1/KRJ 口径句) + TASK-…
docs(dotnet#52): WC01 报告 RECORD-补 —— 三笔推送 head/BYTECHECK + 自 sha16 口径…
docs(dotnet#52): D-G98 一格定罪终局(判词 K3)+ TASK-0111 要件改写(N1 撤销/暂缓、N3 先做、靶…
docs(dotnet#52): WC02 报告 RECORD-补 —— 推送后 head/BYTECHECK(ok=4 mismatch…
fix(shim): 修"鼠标点击不响应" —— 指针抓取掩码补 ButtonPressMask + 残留抓取自愈