Silverlight: How to style the validation tooltip?

元气小坏坏 提交于 2019-12-07 03:35:41

问题


I did some searching but it wasn't what I was looking for. So, does anyone know a way how to style the validation tooltip in Silverlight(the thing in the green border)?

alt text http://img689.imageshack.us/img689/222/validationtooltip.png

Any help would be greatly appreciated!

Best Regards,

~K


回答1:


Unfortunately you can't easily provide a style for the validation tooltip without effectively styling the entire Textbox control. Blend makes this fairly easy if you are familiar with using that design tool. However if your a dyed in the wool coder like me then...

  • Goto this page on MSDN TextBox Styles and Templates
  • Copy the vsm namespace alias to your UserControl xaml
  • Copy the TextBox style into UserControls.Resources give it at an x:Key name (say MyTextBoxStyle")
  • Copy the ValidationToolTipTemplate from the web page to the UserControls.Resources, paste it above the TextBox style. It already has an x:Key name that the TextBox style will be referencing.
  • Add Style="{StaticResource MyTextBoxStyle}" to your TextBox in the data grid.

Now you play around with the validation elements of the templates to get your desired result.




回答2:


The validation messages are displayed as a visual state. you can get to these (and edit them) as templates directly from blend.



来源:https://stackoverflow.com/questions/1899496/silverlight-how-to-style-the-validation-tooltip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!