FrameworkElement.ToolTip FrameworkElement.ToolTip FrameworkElement.ToolTip FrameworkElement.ToolTip Property

定义

获取或设置在用户界面 (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
某些对象 (以对象元素形式提供) 应用作的内容FrameworkElementSome 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. 在此用法中, ToolTip元素是从分析XAMLXAML的隐式创建的, 而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

适用于