问题描述
我进行了一些搜索,但这不是我想要的.那么,有没有人知道如何在 Silverlight 中设置验证工具提示的样式(绿色边框中的东西)?
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)?
替代文字 http://img689.imageshack.us/img689/222/validationtooltip.png
任何帮助将不胜感激!
此致,
~K
推荐答案
很遗憾,如果不有效地设置整个 Textbox 控件的样式,就无法轻松地为验证工具提示提供样式.如果您熟悉使用该设计工具,Blend 会使这变得相当容易.但是,如果您像我一样染上了羊毛编码器,那么...
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...
- 转到 MSDN 上的此页面 TextBox 样式和模板
- 将 vsm 命名空间别名复制到您的 UserControl xaml
- 将 TextBox 样式复制到 UserControls.Resources 中,给它一个 x:Key 名称(比如 MyTextBoxStyle")
- 将 ValidationToolTipTemplate 从网页复制到 UserControls.Resources,将其粘贴到上方文本框样式.它已经有一个 x:Key 名称,TextBox 样式将引用该名称.
- 将
Style="{StaticResource MyTextBoxStyle}"
添加到数据网格中的 TextBox.
- 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.
这篇关于Silverlight:如何设置验证工具提示的样式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!