Archive for November, 2011

WPF: IsSynchronizedWithCurrentItem and ICollectionView Cancel Bug


As some of you may have noticed while working with a Selector-derived control and an ICollectionView, there is a bug with the IsSynchronizedWithCurrentItem property of Selector.  IsSynchronizedWithCurrentItem is provided by Selector to support the ability to keep its SelectedItem in-sync with the CurrentItem of its ItemSource’s ICollectionView. IsSynchronizedWithCurrentItem works perfectly except for one specific case: when the CurrentChanging event of ICollectionView is handled and the item change is cancelled.

In this case the Selector does not respect the cancel and it gets out-of-sync with the ICollectionView. I’d imagine this bug exists because the Selector class was likely implemented before ICollectionView, and Selector was not updated to match the addition. Whatever happened though the bug does exist in WPF 4.0 and can be very problematic. Luckily, with attached properties at our disposable we can work up an easy fix.


Read the rest of this entry »

, , , ,