GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Improved INotifyCollectionChanged Handling · Issue #52 · dotnet/wpf

Improved INotifyCollectionChanged Handling #52

New issue
Copy link
New issue
Copy link
Open
#10845
#9568
Open
Improved INotifyCollectionChanged Handling#52
#10845
#9568
Copy link
Labels
🚧 work in progressEnhancement RequestedProduct code improvement that does NOT require public API changes/additionsPerformancePerformance related issue
Milestone
Future

Description

@Grauenwolf
Grauenwolf
opened on Dec 4, 2018
Issue body actions

This is a carry over from .NET Framework.

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

Activity

Next
  1. dotMorten commented on Dec 4, 2018

    @dotMorten
    dotMorten
    on Dec 4, 2018
    Contributor
    More actions

    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
  2. benaadams commented on Dec 4, 2018

    @benaadams
    benaadams
    on Dec 4, 2018
    Member
    More actions

    The main reason for this original design is that ObservableCollection doesn't have an AddRange method

    The following apis have been approved for Collection<T> and ObservableCollection<T> in .NET Core; though not implemented yet https://github.com/dotnet/corefx/issues/10752:

    public partial class Collection<T>
    {
        public void AddRange(IEnumerable<T> collection);
        public void InsertRange(int index, IEnumerable<T> collection);
        public void RemoveRange(int index, int count);
        public void ReplaceRange(int index, int count, IEnumerable<T> collection);
    
        // These are override by ObservableCollection<T> to raise the event:
        protected virtual void InsertItemsRange(int index, IEnumerable<T> collection);
        protected virtual void RemoveItemsRange(int index, int count);
        protected virtual void ReplaceItemsRange(int index, int count, 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
  3. dotMorten commented on Dec 4, 2018

    @dotMorten
    dotMorten
    on Dec 4, 2018
    Contributor
    More actions

    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)

    Reacted by Jonathan Allen and Peter Moore
  4. airbreather commented on Dec 4, 2018

    @airbreather
    airbreather
    on Dec 4, 2018
    More actions

    most WPF controls will throw an exception.

    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...

    Reacted by Peter Moore
  5. rladuca
    added
    Enhancement RequestedProduct code improvement that does NOT require public API changes/additions
    on Dec 4, 2018
  6. rladuca
    added this to the Future milestone on Dec 4, 2018
  7. YZahringer commented on Apr 18, 2021

    @YZahringer
    YZahringer
    on Apr 18, 2021
    More actions

    Could be a 6.0.0 candidate? This currently blocks the range support in .net 6 ObservableCollection

    Reacted by lindexi and Adam Caviness
  8. DamirLisak commented on Aug 16, 2023

    @DamirLisak
    DamirLisak
    on Aug 16, 2023
    More actions

    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

    case NotifyCollectionChangedAction.Remove:

    In this case, the entire CollectionView would have to be reloaded.

    Reacted by lindexi, Jan Kučera, Damir Lisak, Aleksandar Agincic, Ivan Hrastinski, Mario Žitković, Julien Poulin and dhbprog
  9. symbiogenesis commented on Jan 26, 2024

    @symbiogenesis
    symbiogenesis
    on Jan 26, 2024
    More actions

    This is one of the top-requested features in all of the world of .NET, going back many years. Offering this is crucial.

  10. dotMorten commented on Jul 5, 2024

    @dotMorten
    dotMorten
    on Jul 5, 2024
    Contributor
    More actions

    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
  11. symbiogenesis commented on Jul 8, 2024

    @symbiogenesis
    symbiogenesis
    on Jul 8, 2024
    More actions

    @anjali-wpf @singhashish-wpf

  12. symbiogenesis commented on Jul 8, 2024

    @symbiogenesis
    symbiogenesis
    on Jul 8, 2024
    More actions

    @robertmclaws

  13. rchauhan18
    added
    PerformancePerformance related issue
    on Jul 30, 2024
  14. dotnet-policy-service
    added
    🚧 work in progress
    on Aug 13, 2024
  15. isharrrry
    added a commit that references this issue on Sep 22, 2026

    docs(dotnet#52): 波dotnet#52 前半段登记 —— 新增 D-G100(SetWindowPos(NOSIZE|NO…

    cd90c01
  16. 17 remaining items

  17. isharrrry
    added 14 commits that reference this issue on Sep 23, 2026

    revert(dotnet#52): 还原被 git add -A 夹带进 37def7e 的 W131A 在办 native 源至 do…

    1890b00

    docs(dotnet#52): W127A 报告 §⑪ 发布完整性事件(git add -A 夹带 → 还原发布态)

    8acfbb8

    docs(dotnet#52): W129A 登记批(一)—— 新登记 D-G108(git add -A 夹带别车道在办件进发布)/D-…

    a0a0205

    docs(dotnet#52): W129A 报告 —— 登记批(一)读数与推送(D-G108/D-G109/TASK-0209/TASK…

    966c3c9

    docs(dotnet#52): W129A 报告 RECORD-补 —— 第 2/3 笔推送读数 + BYTECHECK ok=4 + …

    f633fcc

    docs(dotnet#52): W129A 报告 —— 两处表述精度修正(节标题计数口径、报告自身 sha 自指口径)+ 自洽 sha1…

    b75cf3b

    docs(dotnet#52): W129A 报告 RECORD-补 2 —— 推送后复测(含别家 dotnet#53 在办件 verif…

    4b2d7c3

    docs(dotnet#52): TASK-0203 终报收口 ✅(175/175 有效、2 命中同址 0x7fff740dcdf3、上界…

    fb235d4

    docs(dotnet#52): W130A 报告 RECORD-补(推送后 head/BYTECHECK/自 sha16;仅报告自身)

    9241f9f

    docs(dotnet#52): 补推 W128A/W118A 两份证据报告(占位符门 0 命中)+ ROUTES.md §15q(远程 …

    4c3a513

    docs(dotnet#52): WC01 报告 —— 补推两报告 + §15q(DECLDRIFT=1/KRJ 口径句) + TASK-…

    6428396

    docs(dotnet#52): WC01 报告 RECORD-补 —— 三笔推送 head/BYTECHECK + 自 sha16 口径…

    17fa2c6

    docs(dotnet#52): D-G98 一格定罪终局(判词 K3)+ TASK-0111 要件改写(N1 撤销/暂缓、N3 先做、靶…

    d4e3d50

    docs(dotnet#52): WC02 报告 RECORD-补 —— 推送后 head/BYTECHECK(ok=4 mismatch…

    33df6aa
  18. isharrrry
    added a commit that references this issue on Oct 13, 2026

    fix(shim): 修"鼠标点击不响应" —— 指针抓取掩码补 ButtonPressMask + 残留抓取自愈

    d7b9201
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    🚧 work in progressEnhancement RequestedProduct code improvement that does NOT require public API changes/additionsPerformancePerformance related issue

    Type

    No type

    Projects

    No projects

      Milestone

      • FutureNo due date

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402792 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.