In the XAML code in the resources is registered CollectionViewSource

<CollectionViewSource x:Key="viewCollection" Source="{Binding Path=MyCollecthion,Mode=OneWay}"> <CollectionViewSource.GroupDescriptions> <PropertyGroupDescription PropertyName="MyEnum"/> </CollectionViewSource.GroupDescriptions> </CollectionViewSource> 

How to make it so that when the MyEnum property changes, the element is automatically moved to the appropriate group

The MyCollection property returns ObservebleCollecthion <MyType>

The MyEnum property of the MyType class has one of the previously known values.

  • Please correct the viewCollect h ion - semenvx27

1 answer 1

1) You need access to the CollectionViewSource through the key in the form code itself - this is so

viewCollection=(CollectionViewSource)элемент_где_храниться_CVS.Resources["viewCollection"];

2) When changing a property, you need to call the following from this object

  viewCollection.View.Refresh(); 
  • understandable, but not an option, because with 100+ elements, regrouping can occur every second. And it seems very costly in the end will be in performance - Chistyakov Vladislav
  • what it means to regroup more than 100 elements and how expensive it is. This is another question - semenvx27