此页面有用吗?
您对此内容的反馈非常重要。 请告诉我们您的想法。
更多反馈?
1500 个剩余字符
ToolTipService 类
Collapse the table of content
Expand the table of content

ToolTipService 类

Represents a service that provides properties and events to control the display and behavior of tooltips. This class cannot be inherited.

命名空间: System.Windows.Controls
程序集: PresentationFramework(在 presentationframework.dll 中)
XML 命名空间:  http://schemas.microsoft.com/winfx/2006/xaml/presentation

public static class ToolTipService
public final class ToolTipService
public final class ToolTipService
XAML 中不能使用该托管类。

The ToolTipService class attached properties are used to determine the placement, behavior, and appearance of a tooltip. These properties are set on the element that defines the tooltip. You can define tooltip content as a ToolTip object, but this is not required. When you do not define the tooltip content as a ToolTip object, the ToolTipService properties are used to position and customize the tooltip content.

The following example shows a tooltip that is defined for a TextBox and that uses the InitialShowDelay attached property of the ToolTipService to delay the appearance of the tooltip.

<TextBox HorizontalAlignment="Left" ToolTipService.InitialShowDelay="1500"
   ToolTip="Useful information goes here.">
     ToolTip with delay
</TextBox>

You define tooltips for an element by setting the ToolTip property of the element. The ToolTip property of an element is inherited either from FrameworkContentElement.ToolTip or from FrameworkElement.ToolTip.

The ToolTip property takes one child. The content of the child can vary from a simple text string to more complex content such as a StackPanel that has embedded text and Image elements. You can define tooltip content by using a ToolTip object, but this is not required.

The ToolTip class and the ToolTipService class share many of the same properties that are used to customize a tooltip. If equivalent ToolTip and ToolTipService properties are both set, the ToolTipService property takes precedence. For example, if both the ToolTip.Placement property and the ToolTipService.Placement property are set for a System.Windows.Controls.ToolTip object, the value of the ToolTipService.Placement property is used.

The following ToolTipService timing properties are only defined for the ToolTipService class and are used by all tooltips:

For information about how to handle the events that occur when the tooltip opens or closes, see the ToolTipOpeningEvent and ToolTipClosingEvent fields.

This example shows how to set a ToolTipService property that causes a brief delay before a ToolTip displays. You set the properties of the ToolTipService class by attaching them directly to the element that exposes the tooltip.

<TextBox HorizontalAlignment="Left" ToolTipService.InitialShowDelay="1500"
   ToolTip="Useful information goes here.">
     ToolTip with delay
</TextBox>

For the complete sample from which the previous example was extracted, see ToolTip Sample. For a more extensive sample that shows how to get and set the ToolTipService properties in markup and also by using code, see ToolTipService Sample.

更多代码

How to: Position a ToolTip

This example shows how to specify the position of a tooltip on the screen.

How to: Use the BetweenShowDelay Property

This example shows how to use the BetweenShowDelay time property so that tooltips appear quickly—with little or no delay—when a user moves the mouse pointer from one tooltip directly to another.

System.Object
  System.Windows.Controls.ToolTipService

此类型的任何公共静态(Visual Basic 中的 Shared)成员都是线程安全的,但不保证所有实例成员都是线程安全的。

Windows Vista、Microsoft Windows XP SP2 和 Windows Server 2003 SP1 支持 Microsoft .NET Framework 3.0。

.NET Framework

受以下版本支持:3.0

社区附加资源

添加
显示:
© 2015 Microsoft