Visual Class
Definition
Base class for controls that provides rendering and related visual properties.
public class 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
| Name | Description |
|---|---|
| Visual | Initializes a new instance of the Avalonia.Visual class. |
Visual Constructor
Initializes a new instance of the Avalonia.Visual class.
public Visual()
Methods
| Name | Description |
|---|---|
| GetFlowDirection | Gets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. |
| InvalidateVisual | Invalidates the visual and queues a repaint. |
| Render | Renders the visual to a Avalonia.Media.DrawingContext. |
| SetFlowDirection | Sets the value of the attached Avalonia.Visual.FlowDirectionProperty on a control. |
| ApplyStyling | Applies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement. |
| BeginInit | Inherited from StyledElement. |
| EndInit | Inherited from StyledElement. |
| TryGetResource | Inherited from StyledElement. |
| Bind (8 overloads) | Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject. |
| CheckAccess | Returns 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. |
| CoerceValue | Coerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject. |
| Equals | Compares two objects using reference equality. Inherited from AvaloniaObject. |
| GetBaseValue | Inherited from AvaloniaObject. |
| GetHashCode | Gets the hash code for the object. Inherited from AvaloniaObject. |
| GetValue (3 overloads) | Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject. |
| IsAnimating | Checks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject. |
| IsSet | Checks 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. |
| VerifyAccess | Checks 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
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
| Name | Description |
|---|---|
| Bounds | Gets the bounds of the control relative to its parent. |
| CacheMode | Gets or sets the cache mode of the visual. |
| Clip | Gets or sets the geometry clip for this visual. |
| ClipToBounds | Gets or sets a value indicating whether the control should be clipped to its bounds. |
| Effect | Gets or sets the effect of the control. |
| FlowDirection | Gets or sets the text flow direction. |
| HasMirrorTransform | Gets or sets a value indicating whether to apply mirror transform on this control. |
| IsEffectivelyVisible | Gets a value indicating whether this control and all its parents are visible. |
| IsVisible | Gets or sets a value indicating whether this control is visible. |
| Opacity | Gets or sets the opacity of the control. |
| OpacityMask | Gets or sets the opacity mask of the control. |
| RenderTransform | Gets or sets the render transform of the control. |
| RenderTransformOrigin | Gets or sets the transform origin of the control. |
| ZIndex | Gets or sets the Z index of the control. |
| ActualThemeVariant | Gets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement. |
| Classes | Gets or sets the styled element's classes. Inherited from StyledElement. |
| DataContext | Gets or sets the control's data context. Inherited from StyledElement. |
| IsInitialized | Gets a value that indicates whether the element has finished initialization. Inherited from StyledElement. |
| Name | Gets or sets the name of the styled element. Inherited from StyledElement. |
| Parent | Gets the styled element's logical parent. Inherited from StyledElement. |
| Resources | Gets or sets the styled element's resource dictionary. Inherited from StyledElement. |
| StyleKey | Gets the type by which the element is styled. Inherited from StyledElement. |
| Styles | Gets the styles for the styled element. Inherited from StyledElement. |
| TemplatedParent | Gets the styled element whose lookless template this styled element is part of. Inherited from StyledElement. |
| Theme | Gets or sets the theme to be applied to the element. Inherited from StyledElement. |
| Transitions | Gets or sets the property transitions for the control. Inherited from Animatable. |
| Dispatcher | Returns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject. |
| Item | Inherited 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
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
| Name | Description |
|---|---|
| AttachedToVisualTree | Raised when the control is attached to a rooted visual tree. |
| DetachedFromVisualTree | Raised when the control is detached from a rooted visual tree. |
| ActualThemeVariantChanged | Raised when the theme variant is changed on the element or an ancestor of the element. Inherited from StyledElement. |
| AttachedToLogicalTree | Raised when the styled element is attached to a rooted logical tree. Inherited from StyledElement. |
| DataContextChanged | Occurs when the Avalonia.StyledElement.DataContext property changes. Inherited from StyledElement. |
| DetachedFromLogicalTree | Raised when the styled element is detached from a rooted logical tree. Inherited from StyledElement. |
| Initialized | Occurs when the styled element has finished initialization. Inherited from StyledElement. |
| ResourcesChanged | Occurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement. |
| PropertyChanged | Raised 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