Cancel the Property Change

Topics: Issues / bugs
Jul 5, 2012 at 10:26 AM
Edited Jul 5, 2012 at 10:44 AM

Hello again

How is it possible to cancel that a property is changed.


Combobox with some values. The SelectedValue is bind to ActiveItem Property of ViewModel.

When I chosse an value in the combobox i want to  ask a Question with the IMessageService : Change the ActiveItem?
On CancelButton the ActiveItem and so the SelectedValue should not be changed.

Can I do this in PropertyChangedEvent?

Jul 6, 2012 at 9:51 AM

Maybe I found a Solution. But with a problem.

I add an Event to the CollectionViewSource of the Combobox:

CollectionViewSource.GetDefaultView(Recipes).CurrentChanging += RecipeViewCurrentChanging;

In theRecipeViewCurrentChanging i wan't to cancel the event. The problem is that the Event of the ActiveItem Property comes before the RecipeViewCurrentChanging event. :-(

How can I cancel ActiveItem PropertyChanged Event ?

Jul 6, 2012 at 11:32 AM

No. Models and view models in Catel have a PropertyChanging, but there is no way to cancel a change because that *could* cause integrity issues with models. If you want to cancel something from the outside, that is wrong. Then you have to implement this behavior with a custom property on the VM. If the user wants to really change it, change it in the model as well.

Jul 6, 2012 at 12:10 PM

Not realy clear.

The property is not in model just in viewmodel. I just want to cancel that the value is changed in the combobox.

Jul 7, 2012 at 2:24 PM

For now, it is not possible to "undo" a change except by just setting it back. We might implement a cancel option in the future, but the issue is that SL and WP7 and WinRT do not support INotifyPropertyChanging. We have to add this ourselves (not a big deal), but MS makes it hard for us to make sure everything keeps working on all platforms.

Jul 9, 2012 at 7:12 AM
Edited Jul 9, 2012 at 7:12 AM

Is there any workaround to get this functionality? I need this.

Jul 9, 2012 at 6:46 PM

The only 2 options you have at the moment are:

1) Set the previous value back yourself

2) Override SetValue and prevent it there, but you should be really careful with this.

Jul 10, 2012 at 7:06 AM
Edited Jul 10, 2012 at 7:07 AM

1). Thats not possible. When the value have changed a lot of other ViewModels are interested in this property. So i have do a lot of undo work.

2.) Thats wat I've done. Not so easy. Also work in CollectionViewSource.CurrentChanging to reset the value in the combobox.

Jul 11, 2012 at 9:47 AM

I agree that 2 isn't very easy, but I hope it does the job for you now. We will consider a cancel option in the OnPropertyChanging in the future.

Jul 12, 2012 at 8:18 AM

Thanks. Is there a Issue so where I can see when the feature is implemented.

Jul 12, 2012 at 8:22 AM


Jul 12, 2012 at 10:30 AM