Прочетете на английски Редактиране

Споделяне чрез


FrameworkElement.ToolTip Property

Definition

Gets or sets the tool-tip object that is displayed for this element in the user interface (UI).

C#
[System.ComponentModel.Bindable(true)]
[System.Windows.Localizability(System.Windows.LocalizationCategory.ToolTip)]
public object ToolTip { get; set; }

Property Value

The tooltip object.

Attributes

Examples

The following example creates a ToolTip in code and then sets the ToolTip property on a StatusBar control.

C#
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);
}

Remarks

If the value of this property is of type ToolTip, then that value is the tool-tip that will be used in the UI. 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. For more information, see ToolTipService. The service class provides attached properties that can be used to further customize a ToolTip.

XAML Attribute Usage

<object ToolTip="toolTipContent"/>

XAML Property Element Usage

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

-or-

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

XAML Values

toolTipContent A string that becomes the display text for the ToolTip.

toolTipObjectContent Some object, provided in object element form, that should be used as the content for the FrameworkElement. Typically this would be a FrameworkElement or some other element that creates layout compositing for the ToolTip, eventually containing text content within the compositing. In this usage, the ToolTip element is created implicitly from the parsed XAML, and the toolTipObjectContent content is set as its ContentControl.Content property.

<ToolTip .../> See ToolTip.

Dependency Property Information

Item Value
Identifier field ToolTipProperty
Metadata properties set to true None

Applies to

Продукт Версии
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9, 10