Table of Contents

Class ToolTip

Namespace
Avalonia.Controls
Assembly
Avalonia.Controls.dll

A control which pops up a hint when a control is hovered.

[PseudoClasses(new string[] { ":open" })]
public class ToolTip : ContentControl, INotifyPropertyChanged, IDataContextProvider, ILogical, IThemeVariantHost, IResourceHost, IResourceNode, IStyleHost, ISetLogicalParent, ISetInheritanceParent, ISupportInitialize, IStyleable, INamed, IInputElement, IDataTemplateHost, ISetterValue, IPopupHostProvider
Inheritance
ToolTip
Implements
Inherited Members
Extension Methods

Remarks

You will probably not want to create a ToolTip control directly: if added to the tree it will act as a simple ContentControl styled to look like a tooltip. To add a tooltip to a control, use the TipProperty attached property, assigning the content that you want displayed.

Constructors

ToolTip()

public ToolTip()

Fields

BetweenShowDelayProperty

Defines the ToolTip.BetweenShowDelay property.

public static readonly AttachedProperty<int> BetweenShowDelayProperty

Field Value

AttachedProperty<int>

CustomPopupPlacementCallbackProperty

Defines the CustomPopupPlacementCallback property.

public static readonly AttachedProperty<CustomPopupPlacementCallback?> CustomPopupPlacementCallbackProperty

Field Value

AttachedProperty<CustomPopupPlacementCallback>

HorizontalOffsetProperty

Defines the ToolTip.HorizontalOffset property.

public static readonly AttachedProperty<double> HorizontalOffsetProperty

Field Value

AttachedProperty<double>

IsOpenProperty

Defines the ToolTip.IsOpen attached property.

public static readonly AttachedProperty<bool> IsOpenProperty

Field Value

AttachedProperty<bool>

PlacementProperty

Defines the ToolTip.Placement property.

public static readonly AttachedProperty<PlacementMode> PlacementProperty

Field Value

AttachedProperty<PlacementMode>

ServiceEnabledProperty

Defines the ToolTip.ServiceEnabled property.

public static readonly AttachedProperty<bool> ServiceEnabledProperty

Field Value

AttachedProperty<bool>

ShowDelayProperty

Defines the ToolTip.ShowDelay property.

public static readonly AttachedProperty<int> ShowDelayProperty

Field Value

AttachedProperty<int>

ShowOnDisabledProperty

Defines the ToolTip.ShowOnDisabled property.

public static readonly AttachedProperty<bool> ShowOnDisabledProperty

Field Value

AttachedProperty<bool>

TipProperty

Defines the ToolTip.Tip attached property.

public static readonly AttachedProperty<object?> TipProperty

Field Value

AttachedProperty<object>

ToolTipClosingEvent

The event raised when a ToolTip on an element that was shown should now be hidden.

public static readonly RoutedEvent ToolTipClosingEvent

Field Value

RoutedEvent

Remarks

Marking the ToolTipClosing event as handled does not cancel closing the tooltip. Once the tooltip is displayed, closing the tooltip is done only in response to user interaction with the UI.

ToolTipOpeningEvent

The event raised when a ToolTip is going to be shown on an element.

public static readonly RoutedEvent<CancelRoutedEventArgs> ToolTipOpeningEvent

Field Value

RoutedEvent<CancelRoutedEventArgs>

Remarks

To prevent a tooltip from appearing in the UI, your handler for ToolTipOpening can mark the event data handled. Otherwise, the tooltip is displayed, using the value of the ToolTip property as the tooltip content. Another possible scenario is that you could write a handler that resets the value of the ToolTip property for the element that is the event source, just before the tooltip is displayed. ToolTipOpening will not be raised if the value of ToolTip is null or otherwise unset. Do not deliberately set ToolTip to null while a tooltip is open or opening; this will not have the effect of closing the tooltip, and will instead create an undesirable visual artifact in the UI.

VerticalOffsetProperty

Defines the ToolTip.VerticalOffset property.

public static readonly AttachedProperty<double> VerticalOffsetProperty

Field Value

AttachedProperty<double>

Methods

AddToolTipClosingHandler(Control, EventHandler<RoutedEventArgs>)

Adds a handler for the ToolTipClosingEvent attached event.

public static void AddToolTipClosingHandler(Control element, EventHandler<RoutedEventArgs> handler)

Parameters

element Control

Control that listens to this event.

handler EventHandler<RoutedEventArgs>

Event Handler to be removed.

AddToolTipOpeningHandler(Control, EventHandler<CancelRoutedEventArgs>)

Adds a handler for the ToolTipOpeningEvent attached event.

public static void AddToolTipOpeningHandler(Control element, EventHandler<CancelRoutedEventArgs> handler)

Parameters

element Control

Control that listens to this event.

handler EventHandler<CancelRoutedEventArgs>

Event Handler to be added.

GetBetweenShowDelay(Control)

Gets the number of milliseconds since the last tooltip closed during which the tooltip of element will open immediately, or a negative value indicating that the tooltip will always wait for ShowDelayProperty before opening.

public static int GetBetweenShowDelay(Control element)

Parameters

element Control

The control to get the property from.

Returns

int

GetCustomPopupPlacementCallback(Control)

Gets the value of the ToolTip.CustomPopupPlacementCallback attached property.

public static CustomPopupPlacementCallback? GetCustomPopupPlacementCallback(Control element)

Parameters

element Control

Returns

CustomPopupPlacementCallback

GetHorizontalOffset(Control)

Gets the value of the ToolTip.HorizontalOffset attached property.

public static double GetHorizontalOffset(Control element)

Parameters

element Control

The control to get the property from.

Returns

double

A value indicating how the tool tip is positioned.

GetIsOpen(Control)

Gets the value of the ToolTip.IsOpen attached property.

public static bool GetIsOpen(Control element)

Parameters

element Control

The control to get the property from.

Returns

bool

A value indicating whether the tool tip is visible.

GetPlacement(Control)

Gets the value of the ToolTip.Placement attached property.

public static PlacementMode GetPlacement(Control element)

Parameters

element Control

The control to get the property from.

Returns

PlacementMode

A value indicating how the tool tip is positioned.

GetServiceEnabled(Control)

Gets whether showing and hiding of a control's tooltip will be automatically controlled by Avalonia.

public static bool GetServiceEnabled(Control element)

Parameters

element Control

The control to get the property from.

Returns

bool

GetShowDelay(Control)

Gets the value of the ToolTip.ShowDelay attached property.

public static int GetShowDelay(Control element)

Parameters

element Control

The control to get the property from.

Returns

int

A value indicating the time, in milliseconds, before a tool tip opens.

GetShowOnDisabled(Control)

Gets whether a control will display a tooltip even if it disabled.

public static bool GetShowOnDisabled(Control element)

Parameters

element Control

The control to get the property from.

Returns

bool

GetTip(Control)

Gets the value of the ToolTip.Tip attached property.

public static object? GetTip(Control element)

Parameters

element Control

The control to get the property from.

Returns

object

The content to be displayed in the control's tooltip.

GetVerticalOffset(Control)

Gets the value of the ToolTip.VerticalOffset attached property.

public static double GetVerticalOffset(Control element)

Parameters

element Control

The control to get the property from.

Returns

double

A value indicating how the tool tip is positioned.

RemoveToolTipClosingHandler(Control, EventHandler<RoutedEventArgs>)

Removes a handler for the ToolTipClosingEvent attached event.

public static void RemoveToolTipClosingHandler(Control element, EventHandler<RoutedEventArgs> handler)

Parameters

element Control

Control that listens to this event.

handler EventHandler<RoutedEventArgs>

Event Handler to be removed.

RemoveToolTipOpeningHandler(Control, EventHandler<CancelRoutedEventArgs>)

Removes a handler for the ToolTipOpeningEvent attached event.

public static void RemoveToolTipOpeningHandler(Control element, EventHandler<CancelRoutedEventArgs> handler)

Parameters

element Control

Control that listens to this event.

handler EventHandler<CancelRoutedEventArgs>

Event Handler to be removed.

SetBetweenShowDelay(Control, int)

Sets the number of milliseconds since the last tooltip closed during which the tooltip of element will open immediately.

public static void SetBetweenShowDelay(Control element, int value)

Parameters

element Control

The control to get the property from.

value int

The number of milliseconds to set, or a negative value to disable the behaviour.

Remarks

Setting a negative value disables the immediate opening behaviour. The tooltip of element will then always wait until ShowDelayProperty elapses before showing.

SetCustomPopupPlacementCallback(Control, CustomPopupPlacementCallback?)

Sets the value of the ToolTip.CustomPopupPlacementCallback attached property.

public static void SetCustomPopupPlacementCallback(Control element, CustomPopupPlacementCallback? value)

Parameters

element Control
value CustomPopupPlacementCallback

SetHorizontalOffset(Control, double)

Sets the value of the ToolTip.HorizontalOffset attached property.

public static void SetHorizontalOffset(Control element, double value)

Parameters

element Control

The control to get the property from.

value double

A value indicating how the tool tip is positioned.

SetIsOpen(Control, bool)

Sets the value of the ToolTip.IsOpen attached property.

public static void SetIsOpen(Control element, bool value)

Parameters

element Control

The control to get the property from.

value bool

A value indicating whether the tool tip is visible.

SetPlacement(Control, PlacementMode)

Sets the value of the ToolTip.Placement attached property.

public static void SetPlacement(Control element, PlacementMode value)

Parameters

element Control

The control to get the property from.

value PlacementMode

A value indicating how the tool tip is positioned.

SetServiceEnabled(Control, bool)

Sets whether showing and hiding of a control's tooltip will be automatically controlled by Avalonia.

public static void SetServiceEnabled(Control element, bool value)

Parameters

element Control

The control to get the property from.

value bool

Whether the control is to display a tooltip even if it disabled.

SetShowDelay(Control, int)

Sets the value of the ToolTip.ShowDelay attached property.

public static void SetShowDelay(Control element, int value)

Parameters

element Control

The control to get the property from.

value int

A value indicating the time, in milliseconds, before a tool tip opens.

SetShowOnDisabled(Control, bool)

Sets whether a control will display a tooltip even if it disabled.

public static void SetShowOnDisabled(Control element, bool value)

Parameters

element Control

The control to get the property from.

value bool

Whether the control is to display a tooltip even if it disabled.

SetTip(Control, object?)

Sets the value of the ToolTip.Tip attached property.

public static void SetTip(Control element, object? value)

Parameters

element Control

The control to get the property from.

value object

The content to be displayed in the control's tooltip.

SetVerticalOffset(Control, double)

Sets the value of the ToolTip.VerticalOffset attached property.

public static void SetVerticalOffset(Control element, double value)

Parameters

element Control

The control to get the property from.

value double

A value indicating how the tool tip is positioned.