Inconsistency on canceling valuechanging event

Editors for WPF Forum

Posted 4 years ago by Piyush Parsai
Version: 15.1.0622
Platform: .NET 4.5
Environment: Windows 8 (64-bit)


We have following scenario:

I have one property in my viewmodel say BindValue - it is binded to Int32EditBox Value in xaml as Value ="{Binding Path=BindValue, UpdateSourceTrigger=PropertyChanged}"

and we also have subsribed to ValueChanging event, where we check some validation and set e.cancel = true if it doesn't satisfy some condition.

Now, the issue is:

Say we have a Int32EditBox control having its value binded as Value ="{Binding Path=BindValue, UpdateSourceTrigger=PropertyChanged}"

Now say the current value displayed in the control is 5 and the range is 1 to 10, and if user enters say value 11, the BindValue setter is called and the value of BindValue is set to 11, and then ValueChanging event gets fired and we check if it is in the range 1 to 10, as 11 is not in the range we give a meesagebox to the user and set e.cancel = true here, and now in this case the BindValue setter is not called and thus BindValue is still at 11 but the control has reverted to value 5 and thus is showing the value 5 (however the binded property BindValue has value 11).

Please let know, how can we solve this inconsistency.



Comments (3)

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA


Please make a new simple sample project that shows this happening and email it to our support address, referencing this thread.  Be sure to rename the .zip file extension of what you send so it doesn't get spam blocked.  We can try and debug the problem with that.

Actipro Software Support

Posted 4 years ago by Piyush Parsai


I have sent sample on you support address.

Perform following steps on smaple and you can see the problem:

1. Min Value is 5 and Max Value is 20 for Int32Editbox as we can see in tooltip.
2. Change value of Int32EditBox to out of range value i.e. 40.
3. On value out of range message popup click ok, the value will revert to last value.
4. But the BindValue value is not set. To check this click on Check-Actual-BindValue button. You can see that actual bind value is still pointing to out of range value.(i.e. 40) and not to reverted value.

Please suggest us some solution for this issue.


[Modified 4 years ago]

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA

Hi Piyush,

Thanks for the sample.  You were referencing the very old 2011.1 version and this bug appears to have been fixed several years ago in v2011.2.  It works fine in that version and later.

If you can't upgrade to a newer version then I would recommend using the built-in Minimum and Maximum range properties of the edit box instead of your own custom validation logic.

Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 8 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.