|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
Почему CollectionChanged не выстреливает при изменении элемента коллекции? Имеется ObservableCollection<Person>. Person реализует интерфейс INotifyPropertyChanged. Хочется получать уведомления при добавлении удалении и ИЗМЕНЕНИИ элемента. CollectionChanged на удаление/добавление выстреливает, на изменение - нет. Что я делаю неправильно? ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:07 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
RealBlonde, CollectionChanged и не должен выстреливать на изменение. ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:19 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
RealBlondePerson реализует интерфейс INotifyPropertyChanged. Вот Person и должен выстреливать на изменение, покажите как реализован интерфейс INotifyPropertyChanged ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:23 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
Nicky_N, Как же так?! В MSDN написано "Происходит, когда элемент добавляется, удаляется, изменяется или перемещается, а также при обновлении всего списка." ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:23 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
LR, Код: c# 1. 2. 3. 4. 5. 6. 7.
... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:27 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
RealBlonde, тут : It actually works correctly (In response to the post about this event not firing when an item is changed) Yes, it actually does fire when an item is changed. Changing an item does not mean changing a property on the item. It literally means changing or "replacing" the item. Example: collection[item] = newItem; (This causes the CollectionChanged event to be fired.) If you're interested in properties changing on the item (for example, the "FirstName" propety of a Person object in your collection), you should be listening for change events on the item itself, not the ObservableCollection. ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:32 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
RealBlonde, и RaisePropertyChanged вызывается при изменении значений свойств, да? тогда все должно работать... а читать лучше оригинал а не перевод ObservableCollection<T> ClassRepresents a dynamic data collection that provides notifications when items get added, removed, or when the whole list is refreshed. ... Note To fully support transferring data values from binding source objects to binding targets, each object in your collection that supports bindable properties must implement an appropriate property changed notification mechanism such as the INotifyPropertyChanged interface. ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:34 |
|
ObservableCollection & CollectionChanged
|
|||
---|---|---|---|
#18+
Nicky_N, Тоесть если я хочу отслеживать изменения Person'ов в коллекции, то мне надо каждому из них подцепить обработчик на событие PropertyChanged? ... |
|||
:
Нравится:
Не нравится:
|
|||
20.12.2012, 17:36 |
|
|
start [/forum/topic.php?fid=21&msg=38087193&tid=1441549]: |
0ms |
get settings: |
9ms |
get forum list: |
13ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
81ms |
get topic data: |
8ms |
get forum data: |
2ms |
get page messages: |
43ms |
get tp. blocked users: |
1ms |
others: | 308ms |
total: | 471ms |
0 / 0 |