WPF ValidationRule has been trigged, but the TextBox's default errorTemplate did not show red border. - by 木子纵横

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.


1
0
Sign in
to vote
ID 725602 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/19/2012 12:57:55 AM
Access Restriction Public

Description


I create a wpf project only contains a TextBox control. And The TextBox Binds to a ValidationRule .The rule is always return false to test the error template.

1) if The window base class is Window , and call ShowDialog() method. When I input some chars into TextBox, the TextBox 's show the red border, it is ok.
2) if I change the base class from Window to UserControl, insert the usercontrol to another wpf window element, and call Dispath.Run() method in usercontrol. The ValidationRule work correctly and always return false, but the TextBox's default error template did no show red border.
Sign in to post a comment.
Posted by 木子纵横 on 2/20/2012 at 5:32 PM
Thank you very much! It's ok.

I have another question, where can I see these technology details of WPF?
Posted by Microsoft on 2/20/2012 at 12:06 PM
There is no AdornerLayer in which the error template can be drawn.

Window's default style includes an AdornerDecorator, but UserControl's does not. That's because UserControls are frequently used inside a Window or some other context that already supplies an AdornerLayer.

In your case there is no surrounding AdornerLayer, so you need to add one explicitly. In PASimulationView.xaml:

<AdornerDecorator>
     <Grid Background="Yellow">
         ...
     </Grid>
</AdornerDecorator>

You might also want to add a Margin to the TextBox, or do something else to move it away from the top and left edges of the UserControl, so that the top and left edges of the error template are visible.
Posted by Microsoft on 2/20/2012 at 3:24 AM
Thanks for your quick response. We are rerouting this issue to the appropriate group within the Visual Studio Product Team for triage and resolution. These specialized experts will follow-up with your issue.
Posted by 木子纵横 on 2/20/2012 at 1:48 AM
I uploaded a similar demo to MSFT Connect. In the demo, I add a test validationRule in PASimulation project. and I add a TextBox to validate the ErrorTemplate. But the default red border is not show.
Posted by MS-Moderator10 [Feedback Moderator] on 2/19/2012 at 9:50 PM
Thank you for submitting feedback on Visual Studio 2010 and .NET Framework. Could you please give us a demo project to demonstrate this issue?

We look forward to hearing from you with this information.

Microsoft Visual Studio Connect Support Team
Posted by 木子纵横 on 2/19/2012 at 6:11 PM
I'm so sorry for forgeting something:
the usercontrol is hosted to Wpf window. They are two process.
Posted by MS-Moderator01 on 2/19/2012 at 1:42 AM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(http://support.microsoft.com)