Skip to main content

Visual Class

Definition

Namespace:Avalonia
Assembly:Avalonia.Base
Package:Avalonia

Base class for controls that provides rendering and related visual properties.

public class Visual

Inheritance: object -> AvaloniaObject -> Animatable -> StyledElement -> Visual

Derived types:Layoutable

Implements: IAvaloniaListItemValidator<Visual>

Remarks

The Avalonia.Visual class represents elements that have a visual on-screen representation and stores all the information needed for an Avalonia.Rendering.IRenderer to render the control. To traverse the visual tree, use the extension methods defined in Avalonia.VisualExtensions.

Constructors

NameDescription
VisualInitializes a new instance of the Avalonia.Visual class.

Visual Constructor

Initializes a new instance of the Avalonia.Visual class.

public Visual()

Methods

NameDescription
GetFlowDirectionGets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control.
InvalidateVisualInvalidates the visual and queues a repaint.
RenderRenders the visual to a Avalonia.Media.DrawingContext.
SetFlowDirectionSets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control.
ApplyStylingApplies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement.
BeginInitInherited from StyledElement.
EndInitInherited from StyledElement.
TryGetResourceInherited from StyledElement.
Bind (8 overloads)Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject.
CheckAccessReturns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject.
ClearValue (4 overloads)Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject.
CoerceValueCoerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject.
EqualsCompares two objects using reference equality. Inherited from AvaloniaObject.
GetBaseValueInherited from AvaloniaObject.
GetHashCodeGets the hash code for the object. Inherited from AvaloniaObject.
GetValue (3 overloads)Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
IsAnimatingChecks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject.
IsSetChecks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject.
SetCurrentValue (2 overloads)Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject.
SetValue (3 overloads)Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
VerifyAccessChecks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject.

GetFlowDirection Method

Gets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control.

public Avalonia.Media.FlowDirection GetFlowDirection(Avalonia.Visual visual)

Parameters

visual Avalonia.Visual

The control.

Returns

Avalonia.Media.FlowDirection

The flow direction.

InvalidateVisual Method

Invalidates the visual and queues a repaint.

public void InvalidateVisual()

Render Method

Renders the visual to a Avalonia.Media.DrawingContext.

public void Render(Avalonia.Media.DrawingContext context)

Parameters

context Avalonia.Media.DrawingContext

The drawing context.

SetFlowDirection Method

Sets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control.

public void SetFlowDirection(Avalonia.Visual visual, Avalonia.Media.FlowDirection value)

Parameters

visual Avalonia.Visual

The control.

value Avalonia.Media.FlowDirection

The property value to set.

Properties

NameDescription
BoundsGets the bounds of the control relative to its parent.
CacheModeGets or sets the cache mode of the visual.
ClipGets or sets the geometry clip for this visual.
ClipToBoundsGets or sets a value indicating whether the control should be clipped to its bounds.
EffectGets or sets the effect of the control.
FlowDirectionGets or sets the text flow direction.
HasMirrorTransformGets or sets a value indicating whether to apply mirror transform on this control.
IsEffectivelyVisibleGets a value indicating whether this control and all its parents are visible.
IsVisibleGets or sets a value indicating whether this control is visible.
OpacityGets or sets the opacity of the control.
OpacityMaskGets or sets the opacity mask of the control.
RenderTransformGets or sets the render transform of the control.
RenderTransformOriginGets or sets the transform origin of the control.
ZIndexGets or sets the Z index of the control.
ActualThemeVariantGets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement.
ClassesGets or sets the styled element's classes. Inherited from StyledElement.
DataContextGets or sets the control's data context. Inherited from StyledElement.
IsInitializedGets a value that indicates whether the element has finished initialization. Inherited from StyledElement.
NameGets or sets the name of the styled element. Inherited from StyledElement.
ParentGets the styled element's logical parent. Inherited from StyledElement.
ResourcesGets or sets the styled element's resource dictionary. Inherited from StyledElement.
StyleKeyGets the type by which the element is styled. Inherited from StyledElement.
StylesGets the styles for the styled element. Inherited from StyledElement.
TemplatedParentGets the styled element whose lookless template this styled element is part of. Inherited from StyledElement.
ThemeGets or sets the theme to be applied to the element. Inherited from StyledElement.
TransitionsGets or sets the property transitions for the control. Inherited from Animatable.
DispatcherReturns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject.
ItemInherited from AvaloniaObject.

Bounds Property

Gets the bounds of the control relative to its parent.

public Avalonia.Rect Bounds { get; set; }

CacheMode Property

Gets or sets the cache mode of the visual.

public Avalonia.Media.CacheMode CacheMode { get; set; }

Clip Property

Gets or sets the geometry clip for this visual.

public Avalonia.Media.Geometry Clip { get; set; }

ClipToBounds Property

Gets or sets a value indicating whether the control should be clipped to its bounds.

public bool ClipToBounds { get; set; }

Effect Property

Gets or sets the effect of the control.

public Avalonia.Media.IEffect Effect { get; set; }

FlowDirection Property

Gets or sets the text flow direction.

public Avalonia.Media.FlowDirection FlowDirection { get; set; }

HasMirrorTransform Property

Gets or sets a value indicating whether to apply mirror transform on this control.

public bool HasMirrorTransform { get; set; }

IsEffectivelyVisible Property

Gets a value indicating whether this control and all its parents are visible.

public bool IsEffectivelyVisible { get; set; }

IsVisible Property

Gets or sets a value indicating whether this control is visible.

public bool IsVisible { get; set; }

Opacity Property

Gets or sets the opacity of the control.

public double Opacity { get; set; }

OpacityMask Property

Gets or sets the opacity mask of the control.

public Avalonia.Media.IBrush OpacityMask { get; set; }

RenderTransform Property

Gets or sets the render transform of the control.

public Avalonia.Media.ITransform RenderTransform { get; set; }

RenderTransformOrigin Property

Gets or sets the transform origin of the control.

public Avalonia.RelativePoint RenderTransformOrigin { get; set; }

ZIndex Property

Gets or sets the Z index of the control.

public int ZIndex { get; set; }

Remarks

Controls with a higher Avalonia.Visual.ZIndex will appear in front of controls with a lower ZIndex. If two controls have the same ZIndex then the control that appears later in the containing element's children collection will appear on top.

Fields

NameDescription
BoundsPropertyDefines the Avalonia.Visual.Bounds property.
CacheModePropertyDefines the Avalonia.Visual.CacheMode property.
ClipPropertyDefines the Avalonia.Visual.Clip property.
ClipToBoundsPropertyDefines the Avalonia.Visual.ClipToBounds property.
EffectPropertyDefines the Avalonia.Visual.Effect property.
FlowDirectionPropertyDefines the Avalonia.Visual.FlowDirection property.
HasMirrorTransformPropertyDefines the Avalonia.Visual.HasMirrorTransform property.
IsVisiblePropertyDefines the Avalonia.Visual.IsVisible property.
OpacityMaskPropertyDefines the Avalonia.Visual.OpacityMask property.
OpacityPropertyDefines the Avalonia.Visual.Opacity property.
RenderTransformOriginPropertyDefines the Avalonia.Visual.RenderTransformOrigin property.
RenderTransformPropertyDefines the Avalonia.Visual.RenderTransform property.
VisualParentPropertyDefines the Avalonia.Visual.VisualParent property.
ZIndexPropertyDefines the Avalonia.Visual.ZIndex property.
DataContextPropertyDefines the Avalonia.StyledElement.DataContext property. Inherited from StyledElement.
NamePropertyDefines the Avalonia.StyledElement.Name property. Inherited from StyledElement.
ParentPropertyDefines the Avalonia.StyledElement.Parent property. Inherited from StyledElement.
TemplatedParentPropertyDefines the Avalonia.StyledElement.TemplatedParent property. Inherited from StyledElement.
ThemePropertyDefines the Avalonia.StyledElement.Theme property. Inherited from StyledElement.
TransitionsPropertyDefines the Avalonia.Animation.Animatable.Transitions property. Inherited from Animatable.

BoundsProperty Field

Defines the Avalonia.Visual.Bounds property.

public Avalonia.DirectProperty<TOwner,TValue><Avalonia.Visual, Avalonia.Rect> BoundsProperty

CacheModeProperty Field

Defines the Avalonia.Visual.CacheMode property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.CacheMode> CacheModeProperty

ClipProperty Field

Defines the Avalonia.Visual.Clip property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.Geometry> ClipProperty

ClipToBoundsProperty Field

Defines the Avalonia.Visual.ClipToBounds property.

public Avalonia.StyledProperty<TValue><bool> ClipToBoundsProperty

EffectProperty Field

Defines the Avalonia.Visual.Effect property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.IEffect> EffectProperty

FlowDirectionProperty Field

Defines the Avalonia.Visual.FlowDirection property.

public Avalonia.AttachedProperty<TValue><Avalonia.Media.FlowDirection> FlowDirectionProperty

HasMirrorTransformProperty Field

Defines the Avalonia.Visual.HasMirrorTransform property.

public Avalonia.DirectProperty<TOwner,TValue><Avalonia.Visual, bool> HasMirrorTransformProperty

IsVisibleProperty Field

Defines the Avalonia.Visual.IsVisible property.

public Avalonia.StyledProperty<TValue><bool> IsVisibleProperty

OpacityMaskProperty Field

Defines the Avalonia.Visual.OpacityMask property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.IBrush> OpacityMaskProperty

OpacityProperty Field

Defines the Avalonia.Visual.Opacity property.

public Avalonia.StyledProperty<TValue><double> OpacityProperty

RenderTransformOriginProperty Field

Defines the Avalonia.Visual.RenderTransformOrigin property.

public Avalonia.StyledProperty<TValue><Avalonia.RelativePoint> RenderTransformOriginProperty

RenderTransformProperty Field

Defines the Avalonia.Visual.RenderTransform property.

public Avalonia.StyledProperty<TValue><Avalonia.Media.ITransform> RenderTransformProperty

VisualParentProperty Field

Defines the Avalonia.Visual.VisualParent property.

public Avalonia.DirectProperty<TOwner,TValue><Avalonia.Visual, Avalonia.Visual> VisualParentProperty

ZIndexProperty Field

Defines the Avalonia.Visual.ZIndex property.

public Avalonia.StyledProperty<TValue><int> ZIndexProperty

Events

NameDescription
AttachedToVisualTreeRaised when the control is attached to a rooted visual tree.
DetachedFromVisualTreeRaised when the control is detached from a rooted visual tree.
ActualThemeVariantChangedRaised when the theme variant is changed on the element or an ancestor of the element. Inherited from StyledElement.
AttachedToLogicalTreeRaised when the styled element is attached to a rooted logical tree. Inherited from StyledElement.
DataContextChangedOccurs when the Avalonia.StyledElement.DataContext property changes. Inherited from StyledElement.
DetachedFromLogicalTreeRaised when the styled element is detached from a rooted logical tree. Inherited from StyledElement.
InitializedOccurs when the styled element has finished initialization. Inherited from StyledElement.
ResourcesChangedOccurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement.
PropertyChangedRaised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject.

AttachedToVisualTree Event

Raised when the control is attached to a rooted visual tree.

public event EventHandler<Avalonia.VisualTreeAttachmentEventArgs> AttachedToVisualTree

DetachedFromVisualTree Event

Raised when the control is detached from a rooted visual tree.

public event EventHandler<Avalonia.VisualTreeAttachmentEventArgs> DetachedFromVisualTree