FrameworkElement.ToolTip 属性

定义

获取或设置在用户界面 (UI)user interface (UI) 中为此元素显示的工具提示对象。Gets or sets the tool-tip object that is displayed for this element in the 用户界面 (UI)user interface (UI).

public:
 property System::Object ^ ToolTip { System::Object ^ get(); void set(System::Object ^ value); };
[System.ComponentModel.Bindable(true)]
[System.Windows.Localizability(System.Windows.LocalizationCategory.ToolTip)]
public object ToolTip { get; set; }
member this.ToolTip : obj with get, set
Public Property ToolTip As Object

属性值

工具提示对象。The tooltip object.

属性

示例

下面的示例在代码中创建 ToolTip,然后设置 StatusBar 控件上的 ToolTip 属性。The following example creates a ToolTip in code and then sets the ToolTip property on a StatusBar control.

private void MakeProgressBar(object sender, RoutedEventArgs e)
{
    sbar.Items.Clear();
    TextBlock txtb = new TextBlock();
    txtb.Text = "Progress of download.";
    sbar.Items.Add(txtb);
    ProgressBar progressbar = new ProgressBar();
    progressbar.Width = 100;
    progressbar.Height = 20;
    Duration duration = new Duration(TimeSpan.FromSeconds(5));
    DoubleAnimation doubleanimation =
                               new DoubleAnimation(100.0, duration);
    progressbar.BeginAnimation(ProgressBar.ValueProperty,
                               doubleanimation);
    ToolTip ttprogbar = new ToolTip();
    ttprogbar.Content = "Shows the progress of a download.";
    progressbar.ToolTip = (ttprogbar);
    sbar.Items.Add(progressbar);
}
Private Sub MakeProgressBar(ByVal sender As Object, ByVal e As RoutedEventArgs)
    sbar.Items.Clear()
    Dim txtb As New TextBlock()
    txtb.Text = "Progress of download."
    sbar.Items.Add(txtb)
    Dim progressbar As New ProgressBar()
    progressbar.Width = 100
    progressbar.Height = 20
    Dim duration As New Duration(TimeSpan.FromSeconds(5))
    Dim doubleanimation As New DoubleAnimation(100.0, duration)
    progressbar.BeginAnimation(ProgressBar.ValueProperty, doubleanimation)
    Dim ttprogbar As New ToolTip()
    ttprogbar.Content = "Shows the progress of a download."
    progressbar.ToolTip = (ttprogbar)
    sbar.Items.Add(progressbar)
End Sub

注解

如果此属性的值为 ToolTip类型,则该值是将在 UIUI中使用的工具提示。If the value of this property is of type ToolTip, then that value is the tool-tip that will be used in the UIUI. 如果值为任何其他类型,则该值将用作由系统提供(构造) ToolTip内容If the value is of any other type, then that value will be used as the content for a ToolTip provided (constructed) by the system. 有关详细信息,请参阅 ToolTipServiceFor more information, see ToolTipService. 服务类提供附加属性,这些属性可用于进一步自定义 ToolTipThe service class provides attached properties that can be used to further customize a ToolTip.

XAML 属性用法XAML Attribute Usage

<object ToolTip="toolTipContent"/>  

XAML 属性元素用法XAML Property Element Usage

<object>  
  <object.ToolTip>  
    <ToolTip .../>  
  </object.ToolTip>  
</object>

-or-

<object>  
  <object.ToolTip>  
    toolTipObjectContent  
  </object.ToolTip>  
</object>  

XAML 值XAML Values

toolTipContenttoolTipContent
一个字符串,该字符串将成为 ToolTip的显示文本。A string that becomes the display text for the ToolTip.

toolTipObjectContenttoolTipObjectContent
某些对象(以对象元素形式提供)应用作 FrameworkElement 的内容。Some object, provided in object element form, that should be used as the content for the FrameworkElement . 通常,这将是 FrameworkElement 或为 ToolTip创建布局组合的其他元素,最终包含组合内的文本内容。Typically this would be a FrameworkElement or some other element that creates layout compositing for the ToolTip, eventually containing text content within the compositing. 在此用法中,将从分析的 XAMLXAML隐式创建 ToolTip 元素,并将toolTipObjectContent内容设置为其 ContentControl.Content 属性。In this usage, the ToolTip element is created implicitly from the parsed XAMLXAML, and the toolTipObjectContent content is set as its ContentControl.Content property.

<ToolTip .../><ToolTip .../>
请参阅 ToolTipSee ToolTip.

依赖项属性信息Dependency Property Information

标识符字段Identifier field ToolTipProperty
元数据属性设置为 trueMetadata properties set to true NoneNone

适用于