{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/10752","repository_url":"https://api.github.com/repos/dotnet/corefx","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/10752/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/10752/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/10752/events","html_url":"https://github.com/dotnet/corefx/issues/10752","id":170996032,"number":10752,"title":"ObservableCollection has no \"AddRange\" support","user":{"login":"robertmclaws","id":1657085,"avatar_url":"https://avatars.githubusercontent.com/u/1657085?v=3","gravatar_id":"","url":"https://api.github.com/users/robertmclaws","html_url":"https://github.com/robertmclaws","followers_url":"https://api.github.com/users/robertmclaws/followers","following_url":"https://api.github.com/users/robertmclaws/following{/other_user}","gists_url":"https://api.github.com/users/robertmclaws/gists{/gist_id}","starred_url":"https://api.github.com/users/robertmclaws/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robertmclaws/subscriptions","organizations_url":"https://api.github.com/users/robertmclaws/orgs","repos_url":"https://api.github.com/users/robertmclaws/repos","events_url":"https://api.github.com/users/robertmclaws/events{/privacy}","received_events_url":"https://api.github.com/users/robertmclaws/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/dotnet/corefx/labels/Feature","name":"Feature","color":"5319e7"},{"url":"https://api.github.com/repos/dotnet/corefx/labels/System.Collections","name":"System.Collections","color":"d4c5f9"}],"state":"open","locked":false,"assignee":{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false},"assignees":[{"login":"Priya91","id":7853870,"avatar_url":"https://avatars.githubusercontent.com/u/7853870?v=3","gravatar_id":"","url":"https://api.github.com/users/Priya91","html_url":"https://github.com/Priya91","followers_url":"https://api.github.com/users/Priya91/followers","following_url":"https://api.github.com/users/Priya91/following{/other_user}","gists_url":"https://api.github.com/users/Priya91/gists{/gist_id}","starred_url":"https://api.github.com/users/Priya91/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Priya91/subscriptions","organizations_url":"https://api.github.com/users/Priya91/orgs","repos_url":"https://api.github.com/users/Priya91/repos","events_url":"https://api.github.com/users/Priya91/events{/privacy}","received_events_url":"https://api.github.com/users/Priya91/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/dotnet/corefx/milestones/4","html_url":"https://github.com/dotnet/corefx/milestones/1.2.0","labels_url":"https://api.github.com/repos/dotnet/corefx/milestones/4/labels","id":1248719,"number":4,"title":"1.2.0","description":".NET Core 1.2 Placeholder.  https://github.com/dotnet/core/blob/master/roadmap.md","creator":{"login":"joshfree","id":1302850,"avatar_url":"https://avatars.githubusercontent.com/u/1302850?v=3","gravatar_id":"","url":"https://api.github.com/users/joshfree","html_url":"https://github.com/joshfree","followers_url":"https://api.github.com/users/joshfree/followers","following_url":"https://api.github.com/users/joshfree/following{/other_user}","gists_url":"https://api.github.com/users/joshfree/gists{/gist_id}","starred_url":"https://api.github.com/users/joshfree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshfree/subscriptions","organizations_url":"https://api.github.com/users/joshfree/orgs","repos_url":"https://api.github.com/users/joshfree/repos","events_url":"https://api.github.com/users/joshfree/events{/privacy}","received_events_url":"https://api.github.com/users/joshfree/received_events","type":"User","site_admin":false},"open_issues":635,"closed_issues":1060,"state":"open","created_at":"2015-08-10T18:04:00Z","updated_at":"2016-09-13T16:47:52Z","due_on":"2017-04-30T07:00:00Z","closed_at":null},"comments":2,"created_at":"2016-08-13T06:31:14Z","updated_at":"2016-09-13T19:48:33Z","closed_at":null,"body":"So the `ObservableCollection` is one of the cornerstones of software development, not just in Windows, but on the web. One issue that comes up constantly is that, while the `OnCollectionChanged` event has a structure and constructors that support signaling the change for multiple items being added, the `ObservableCollection` does not have a method to support this.\r\n\r\nIf you look at the web as an example, Knockout has a way to be able to add multiple items to the collection, but not signal the change until the very end. The `ObservableCollection` needs the same functionality, but does not have it.\r\n\r\nIf you look at other extension methods to solve this problem, like the one in [Template10](https://github.com/Windows-XAML/Template10/blob/master/Template10%20(Library)/Utils/IEnumerableUtils.cs#L34-L45), they let you add multiple items, but do not solve the signaling problem. That's because the `ObservableCollection.InsertItem()` method overrides `Collection.InsertItem()`, and all of the other methods are private. So the only way to fix this properly is in the `ObservableCollection` itself.\r\n\r\nI'm proposing an \"AddRange\" function that accepts an existing collection as input, optionally clears the collection before adding, and then throws the `OnCollectionChanging` event AFTER all the objects have been added. I have already implemented this in a PR #10751 so you can see what the implementation would look like.\r\n\r\nI look forward to your feedback. Thanks!"},"comment":{"url":"https://api.github.com/repos/dotnet/corefx/issues/comments/246801590","html_url":"https://github.com/dotnet/corefx/issues/10752#issuecomment-246801590","issue_url":"https://api.github.com/repos/dotnet/corefx/issues/10752","id":246801590,"user":{"login":"thomaslevesque","id":1864281,"avatar_url":"https://avatars.githubusercontent.com/u/1864281?v=3","gravatar_id":"","url":"https://api.github.com/users/thomaslevesque","html_url":"https://github.com/thomaslevesque","followers_url":"https://api.github.com/users/thomaslevesque/followers","following_url":"https://api.github.com/users/thomaslevesque/following{/other_user}","gists_url":"https://api.github.com/users/thomaslevesque/gists{/gist_id}","starred_url":"https://api.github.com/users/thomaslevesque/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomaslevesque/subscriptions","organizations_url":"https://api.github.com/users/thomaslevesque/orgs","repos_url":"https://api.github.com/users/thomaslevesque/repos","events_url":"https://api.github.com/users/thomaslevesque/events{/privacy}","received_events_url":"https://api.github.com/users/thomaslevesque/received_events","type":"User","site_admin":false},"created_at":"2016-09-13T19:48:33Z","updated_at":"2016-09-13T19:48:33Z","body":"A long time ago I had implemented a [`RangeObservableCollection`](https://bitbucket.org/tom103/dvp.net/src/ceea289857cd260b9a4335d2c3f2f02d801a3c69/src/Developpez.Dotnet.Windows/Collections/RangeObservableCollection.cs?at=master&fileviewer=file-view-default) with `AddRange`, `RemoveRange`, `InsertRange`, `ReplaceRange` and `RemoveAll`. But it turned out that the WPF binding system didn't support `CollectionChanged` notifications with multiple items (I seem to remember it has been fixed since then, but I'm not sure)."}}
{"actor":{"display_login":"thomaslevesque"}}