-->

ICollectionView cancel currentchanging

2019-07-15 10:26发布

问题:

I am looking for a way to cancel the CurrentChanging event depending on the item that was clicked. In my application I use ICollectionView to hold my list of viewmodels which are rendered as tabitems in a tabcontrol. For a specific viewmodel I need to do some property checking before the viewmodel can be activated. In order to do that I need to now that the specific viewmodel is going to be the next current item. Depending on the results of the property checking, the change of the current item should be allowed or canceled (only for the specific viewmodel). I don't want to do the property checking for all the other viewmodels.

Is there a way to have access to the next current item before it is set?

Edit:

Another idea: in the currentchanged event I do my property checking and depending on its result, I send a message to the parent view model (which contains the list of view models) to trigger it to move current to first. I would expect this to trigger a new current change event but it does not. The current item always is the view model that was selected before the first current changed event.

What's happening there?