
原文地址: http://www.dingos.cn/index.php?topic=2000.0
第二十九章 为 Silverlight 控件添加 工具提示Silverlight 提供了一个名为“ tooltipService ”的控件用 于为 Silverlight 控件显示工具提示。这个类可以附着在 Silverlight 中的大多数 UI 元素上用于显示工具提示。
简 单的文本提示下面的示例代码显示如何为一个按钮控件添加工具提示:
< button WIDth ="60" Height ="20" Content ="My button">
< tooltipService.tooltip >
< tooltip Content ="This is tool tip for button"></ tooltip >
</ tooltipService.tooltip >
</ button >
看下面的示例用于为文本框控件设置工具提示:
< TextBlock WIDth ="60" Height ="20" Text ="My Text">
< tooltipService.tooltip >
< tooltip Content ="This is tool tip for TextBlock"></ tooltip >
</ tooltipService.tooltip >
</ TextBlock >
显 示富 UI 元素提示Silverlight 在工具提示时支持 UI 元素,使用户得到更好的体验。在工具 提示时可以使用更多的 UI 元素。看下面显示的例子
在提示工具中显示图像
示例代码显示在 Silverlight 中如何显示图像工具提示:
< TextBox WIDth ="60" Height ="20" Text ="My Text">
< tooltipService.tooltip >
< Image Source ="http://www.dotnetspIDer.com/images/spIDerlogo.jpg" >
</ Image >
</ tooltipService.tooltip >
</ TextBox >
为整个 Silverlight 控件进行提示
可以为整个 Silverlight 工具设置提示。看如下代码:
< UserControl x : Class ="MySilverlightApp.Page"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns : x ="http://schemas.microsoft.com/winfx/2006/xaml"
WIDth ="400" Height ="300">
< StackPanel x : name ="LayoutRoot" Background ="White">
< tooltipService.tooltip >
< tooltip Content ="This is tool tip for entire control"></ tooltip >
</ tooltipService.tooltip >
</ StackPanel >
</ UserControl >
编 程方式设置工具提示可以从后台代码文件设置或改变工具提示。下面例子显示如何从后台代码文件为按钮控件设置文本提 示:
tooltipService .Settooltip(Mybutton,"This is new tooltip" );
总结以上是内存溢出为你收集整理的Silverlight入门学习(29)全部内容,希望文章能够帮你解决Silverlight入门学习(29)所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)