FrameworkElement.ToolTip 屬性

定義

取得或設定在使用者介面中為這個專案顯示的工具提示物件, (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

屬性值

工具提示物件。

屬性

範例

下列範例會在 ToolTip 程式碼中建立 ,然後在 控制項上 StatusBar 設定 ToolTip 屬性。

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 ,則該值會是 UI 中使用的工具提示。 如果值屬於任何其他類型,則該值會當做系統所建構) 所提供 (內容ToolTip 使用。 如需詳細資訊,請參閱ToolTipService。 服務類別提供附加屬性,可用來進一 ToolTip 步自訂 。

XAML Attribute Usage

<object ToolTip="toolTipContent"/>  

XAML 屬性項目用法

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

-或-

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

XAML 值

toolTipContent
字串,成為 的 ToolTip 顯示文字。

toolTipObjectContent
某些物件是以物件專案形式提供,應該用來做為 的內容 FrameworkElement 。 一般而言,這會是 FrameworkElement 或一些其他元素,會建立 的 ToolTip 版面配置撰寫,最後在撰寫中包含文字內容。 在此用法中 ToolTip ,會從剖析的 XAML 隱含建立 元素,並將 toolTipObjectContent 內容設定為其 ContentControl.Content 屬性。

<ToolTip .../>
請參閱 ToolTip

相依性屬性資訊

識別碼欄位 ToolTipProperty
中繼資料屬性設定為 true

適用於