inotifycollectionchanged

How can I raise a CollectionChanged event on an ObservableCollection, and pass it the changed items?

大兔子大兔子 提交于 2019-11-29 10:53:50
问题 I have a class that inherits from ObservableCollection and adds a few additional methods such as AddRange and RemoveRange My base method call is this: public void AddRange(IEnumerable<T> collection) { foreach (var i in collection) Items.Add(i); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset)); } My problem with this is that I want to access e.NewItems or e.OldItems in the CollectionChanged event to perform an action on whatever item is in the

what is notifycollectionchangedaction reset value

六眼飞鱼酱① 提交于 2019-11-28 11:58:35
I have an observable collection... SelectableDataContext<T> ..And in the generic class SelectableDataContext<T> is...having two private member variables Private T item. Private bool isSelected. When the IsSelected property changes...My collection's changed property is not firing . I think it should fire...because it's Reset in INotifyCollectionChangedAction . G. Lombard This is an old question but for the benefit of anyone who may come across this through a search as I did: NotifyCollectionChangedAction.Reset means "The content of the collection changed dramatically". One case where the Reset

ObservableCollection element-wise Transform/Projection Wrapper

那年仲夏 提交于 2019-11-28 08:26:32
When creating ViewModels in WPF it's sometimes necessary to transform data that is available in an ObservableCollection (the source collection) into a collection of wrapper elements that extend/restrict/project the original elements (the target collection), while the number and order of the elements always mirror the original collection. Just like the Select extension method, except that it is continuously updated and can therefore be used for WPF bindings. If an element is added to the source at index x, the Wrapper of the same element is added at the same index x in the target collection. If

How do I update an IValueConverter on CollectionChanged?

删除回忆录丶 提交于 2019-11-28 08:01:00
问题 Here's a basic example to explain my problem. Let's say I have ObservableCollection<int> Numbers {get; set;} and an IValueConverter that returns the sum of Numbers. Normally what I'd do is changed the IValueConverter into an IMultiValueConverter and bind a second value to Numbers.Count like this <MultiBinding Converter="{StaticResource SumTheIntegersConverter}"> <Binding Path="Numbers" /> <Binding Path="Numbers.Count" /> </MultiBinding> However I'm unable to use this method to solve my actual

ObservableCollection element-wise Transform/Projection Wrapper

强颜欢笑 提交于 2019-11-27 02:13:12
问题 When creating ViewModels in WPF it's sometimes necessary to transform data that is available in an ObservableCollection (the source collection) into a collection of wrapper elements that extend/restrict/project the original elements (the target collection), while the number and order of the elements always mirror the original collection. Just like the Select extension method, except that it is continuously updated and can therefore be used for WPF bindings. If an element is added to the

what is notifycollectionchangedaction reset value

孤街醉人 提交于 2019-11-26 21:47:05
问题 I have an observable collection... SelectableDataContext<T> ..And in the generic class SelectableDataContext<T> is...having two private member variables Private T item. Private bool isSelected. When the IsSelected property changes...My collection's changed property is not firing . I think it should fire...because it's Reset in INotifyCollectionChangedAction . 回答1: This is an old question but for the benefit of anyone who may come across this through a search as I did:

Observable Stack and Queue

谁说我不能喝 提交于 2019-11-26 21:01:20
I'm looking for an INotifyCollectionChanged implementation of Stack and Queue . I could roll my own but I don't want to reinvent the wheel. With Stacks and Queues (almost by definition) you only have access to the top of the stack or head of the queue. It's what differentiates them from a List . (and so, that's why you haven't found one) To answer though you could write your own, I would do it by deriving from ObservableCollection , then in the case of a stack implementing the Push as an Insert at offset 0 (and pop as returning index 0 then RemoveAt index 0); or with a queue you could just Add

Observable Stack and Queue

对着背影说爱祢 提交于 2019-11-26 07:47:59
问题 I\'m looking for an INotifyCollectionChanged implementation of Stack and Queue . I could roll my own but I don\'t want to reinvent the wheel. 回答1: With Stacks and Queues (almost by definition) you only have access to the top of the stack or head of the queue. It's what differentiates them from a List . (and so, that's why you haven't found one) To answer though you could write your own, I would do it by deriving from ObservableCollection , then in the case of a stack implementing the Push as

ObservableCollection Doesn&#39;t support AddRange method, so I get notified for each item added, besides what about INotifyCollectionChanging?

若如初见. 提交于 2019-11-25 23:46:21
问题 I want to be able to add a range and get updated for the entire bulk. I also want to be able to cancel the action before it\'s done (i.e. collection changing besides the \'changed\'). Related Q Which .Net collection for adding multiple objects at once and getting notified? 回答1: Please refer to the updated and optimized C# 7 version. I didn't want to remove the VB.NET version so I just posted it in a separate answer. Go to updated version Seems it's not supported, I implemented by myself, FYI,