illegal-immigrant
illegal-immigrant

Reputation: 8254

WPF Refresh CollectionView without explicit recreation (Refresh() method call)

Is it possible to 'refresh'(update) a view without explicit Refresh() method call? The problem is that it recreates a whole collection, and on UI, selected row becomes unselected. I have a complex list view (each row contains another sub-listview) and when I call Refresh(), selection in sub-rows disappears. Clearing SortDescriptions and adding them again manually doesn't work for me (It seems that both Clear() and Add() sort description's methods calls Refresh() internally)

So, any chance to get view updated without it recreation?

My situation : Using Dispatcher.Timer I'm updating all the properties for each item manually (to avoid selection disappear), then update one item's list-type property (property with another one collection, it is updating 'manually' too) and then I need to refresh a view somehow, when I call Refresh() on sub-collection, everything is OK, but I also need to refresh a top-level collection too, to get sort descriptions applied to top-level collection, which was probably changed.

Upvotes: 9

Views: 14615

Answers (2)

Joel Lucsy
Joel Lucsy

Reputation: 8706

Another option is to use ContinuousLinq to keep the view sorted/grouped at all times.

Upvotes: 1

illegal-immigrant
illegal-immigrant

Reputation: 8254

Found a solution in this great blog post : DrWPF

Upvotes: 9

Related Questions