|
-
Nov 24th, 2010, 05:50 AM
#1
ExceptionValidationRule bug?
I'm trying to do some simple TextBox validation and found the ExceptionValidationRule class. My XAML is (basically)
Code:
<TextBox>
<TextBox.Text>
<Binding Path="MyText" UpdateSourceTrigger="PropertyChanged">
<Binding.ValidationRules>
<ExceptionValidationRule />
</Binding.ValidationRules>
</Binding>
</TextBox.Text>
</TextBox>
and the MyText property is (basically)
Code:
public string MyText {
get { return this.myText; }
set {
this.myText = value;
if (!MyTextIsValid(value))
throw new ApplicationException("Not valid.");
else
OnPropertyChanged("MyText"); } }
When run in debug mode, if I edit the text so that it becomes invalid, instead of just outlining the TextBox in red like I want, a debug window comes up saying the "Not valid." application exception was unhandled. When run outside of debug mode, it works properly.
I ran someone else's example code, though it wasn't written for VS2010. After running the upgrade wizard and the application, the same error appears. I also found a forum post which seems to describe my issue precisely, though it had no replies.
Since I've never used data validation before, I wanted to make sure I wasn't doing anything wrong and that this is indeed a bug. So, anybody have confirmation it's a bug or advice on what I'm doing wrong?
P.S. I'm aware there should be workarounds with the more complex validation techniques. I don't want to use them on principle, particularly since the non-debug version works fine.
The time you enjoy wasting is not wasted time.
Bertrand Russell
<- Remember to rate posts you find helpful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|