I have an ItemsControl bound to a sorted (via CollectionViewSource) derived ObservableCollection of view models. In my derived collection class, I'm handling PropertyChanged on my vi开发者_开发技巧ew models. When a certain property (Order) has changed I need the rendering of the controls to reflect the new, sorted collection.
I understand, that in my handling of PropertyChanged, I can call OnCollectionChanged with the Reset action specified; however, this leads to loss of focus on the control, which is undesirable for my situation.
Is there anyway I can handle the change and have a smooth transition with the cursor remaining where it is (or in the case of a tab, move to the next appropriate field).
What changes the Order
property?
Perhaps you can look into re-arranging your ItemsControl instead of sorting and refreshing your source.
I did this in the past with a TabControl. When a user Drags/Drops a tab into a new location, it removes the actual TabItem from the TabControl and inserts it in the new location. The SelectedTab was never altered so I didn't have to worry about focus changing.
精彩评论