Class ToolTip
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
CustomPopupPlacementCallbackProperty
Defines the CustomPopupPlacementCallback property.
public static readonly AttachedProperty<CustomPopupPlacementCallback?> CustomPopupPlacementCallbackProperty
Field Value
HorizontalOffsetProperty
Defines the ToolTip.HorizontalOffset property.
public static readonly AttachedProperty<double> HorizontalOffsetProperty
Field Value
IsOpenProperty
Defines the ToolTip.IsOpen attached property.
public static readonly AttachedProperty<bool> IsOpenProperty
Field Value
PlacementProperty
Defines the ToolTip.Placement property.
public static readonly AttachedProperty<PlacementMode> PlacementProperty
Field Value
ServiceEnabledProperty
Defines the ToolTip.ServiceEnabled property.
public static readonly AttachedProperty<bool> ServiceEnabledProperty
Field Value
ShowDelayProperty
Defines the ToolTip.ShowDelay property.
public static readonly AttachedProperty<int> ShowDelayProperty
Field Value
ShowOnDisabledProperty
Defines the ToolTip.ShowOnDisabled property.
public static readonly AttachedProperty<bool> ShowOnDisabledProperty
Field Value
TipProperty
Defines the ToolTip.Tip attached property.
public static readonly AttachedProperty<object?> TipProperty
Field Value
ToolTipClosingEvent
The event raised when a ToolTip on an element that was shown should now be hidden.
public static readonly RoutedEvent ToolTipClosingEvent
Field Value
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
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
Methods
AddToolTipClosingHandler(Control, EventHandler<RoutedEventArgs>)
Adds a handler for the ToolTipClosingEvent attached event.
public static void AddToolTipClosingHandler(Control element, EventHandler<RoutedEventArgs> handler)
Parameters
element
ControlControl 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
ControlControl 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
ControlThe control to get the property from.
Returns
GetCustomPopupPlacementCallback(Control)
Gets the value of the ToolTip.CustomPopupPlacementCallback attached property.
public static CustomPopupPlacementCallback? GetCustomPopupPlacementCallback(Control element)
Parameters
element
Control
Returns
GetHorizontalOffset(Control)
Gets the value of the ToolTip.HorizontalOffset attached property.
public static double GetHorizontalOffset(Control element)
Parameters
element
ControlThe 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
ControlThe 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
ControlThe 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
ControlThe control to get the property from.
Returns
GetShowDelay(Control)
Gets the value of the ToolTip.ShowDelay attached property.
public static int GetShowDelay(Control element)
Parameters
element
ControlThe 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
ControlThe control to get the property from.
Returns
GetTip(Control)
Gets the value of the ToolTip.Tip attached property.
public static object? GetTip(Control element)
Parameters
element
ControlThe 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
ControlThe 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
ControlControl 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
ControlControl 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
ControlThe control to get the property from.
value
intThe 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
Controlvalue
CustomPopupPlacementCallback
SetHorizontalOffset(Control, double)
Sets the value of the ToolTip.HorizontalOffset attached property.
public static void SetHorizontalOffset(Control element, double value)
Parameters
element
ControlThe control to get the property from.
value
doubleA 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
ControlThe control to get the property from.
value
boolA 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
ControlThe control to get the property from.
value
PlacementModeA 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
ControlThe control to get the property from.
value
boolWhether 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
ControlThe control to get the property from.
value
intA 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
ControlThe control to get the property from.
value
boolWhether 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
ControlThe control to get the property from.
value
objectThe 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)