Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 243
illegal-immigrant Avatar asked Apr 07 '11 14:04

illegal-immigrant


2 Answers

Found a solution in this great blog post : DrWPF

like image 187
illegal-immigrant Avatar answered Oct 05 '22 02:10

illegal-immigrant


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

like image 22
Joel Lucsy Avatar answered Oct 05 '22 03:10

Joel Lucsy