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; }
[<System.ComponentModel.Bindable(true)>]
[<System.Windows.Localizability(System.Windows.LocalizationCategory.ToolTip)>]
member this.ToolTip : obj with get, set
Public Property ToolTip As Object

屬性值

Object

工具提示物件。The tooltip object.

屬性

範例

下列範例會在程式 ToolTip 代碼中建立,然後在 ToolTip 控制項上設定屬性 StatusBarThe 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 ,則該值是將在中使用的工具提示 UIUIIf the value of this property is of type ToolTip, then that value is the tool-tip that will be used in the UIUI. 如果值為任何其他類型,則會使用該值做為系統所建立的content 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 Attribute UsageXAML 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
字串,這個字串會成為的顯示文字 ToolTipA 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 None

適用於