Silverlight validation message location
While using the default validation handling in Silverlight ( using ValidatesOnExceptions=True,NotifyOnValidationError=True),
you typically get the exception message towards the side the textbox. I would like the change the location of the validat开发者_Python百科ion message (exception message) and put it on the top of textbox. Any ideas on how I can do it. I could not find any literature on changing the error message location on the net.This is (IMO) a sad oversight in the default validation UI. There should be a way for you to specify the ToolTip placement value, instead the placement value is fixed in the template to be "Right".
Hence to change this you need to visit this MSDN topic Textbox Styles and Templates, make a copy of the TextBox
default style and the referenced "ValidationToolTipTemplate". Add these to a fresh ResourceDictionary
file and give the TextBox
Style
a Key value. You can now adjust the validation tooltip Placement
property in the text box template.
Include this new ResourceDictionary
as merged dictionary in either your App.Xaml or your UserControl/Page resources and assign this style to your TextBox
Style
property.
Excessive mucking about for just a simple change but there is no other way. On the upside you can do all sorts of other things with the text box style and/or the Validation tooltip now that you have them in your own code.
精彩评论