StyledElement Class

Summary

Extends an Animatable with the following features: - An inherited DataContext. - Implements IStyleable to allow styling to work on the styled element. - Implements ILogical to form part of a logical tree. - A collection of class strings for custom styling.
graph TD Base0["Animatable"]-->Type click Base0 "/api/Avalonia.Animation/Animatable" Base1["AvaloniaObject"]-->Base0 click Base1 "/api/Avalonia/AvaloniaObject" Base2["object"]-->Base1 Interface0["IAvaloniaObjectDebug"]-.->Type click Interface0 "/api/Avalonia.Diagnostics/IAvaloniaObjectDebug" Interface1["INotifyPropertyChanged"]-.->Type Interface2["IStyledElement"]-.->Type click Interface2 "/api/Avalonia/IStyledElement" Interface3["IStyleable"]-.->Type click Interface3 "/api/Avalonia.Styling/IStyleable" Interface4["IAvaloniaObject"]-.->Type click Interface4 "/api/Avalonia/IAvaloniaObject" Interface5["INamed"]-.->Type click Interface5 "/api/Avalonia/INamed" Interface6["IStyleHost"]-.->Type click Interface6 "/api/Avalonia.Styling/IStyleHost" Interface7["ILogical"]-.->Type click Interface7 "/api/Avalonia.LogicalTree/ILogical" Interface8["IResourceNode"]-.->Type click Interface8 "/api/Avalonia.Controls/IResourceNode" Interface9["IResourceProvider"]-.->Type click Interface9 "/api/Avalonia.Controls/IResourceProvider" Interface10["ISetLogicalParent"]-.->Type click Interface10 "/api/Avalonia.Controls/ISetLogicalParent" Interface11["ISetInheritanceParent"]-.->Type click Interface11 "/api/Avalonia.Controls/ISetInheritanceParent" Type["StyledElement"] class Type type-node Type-->Derived0["Visual"] click Derived0 "/api/Avalonia/Visual"

Syntax

public class StyledElement : Animatable, IAvaloniaObjectDebug, INotifyPropertyChanged, 
    IStyledElement, IStyleable, IAvaloniaObject, INamed, IStyleHost, ILogical, IResourceNode, 
    IResourceProvider, ISetLogicalParent, ISetInheritanceParent

Constructors

Name Summary
StyledElement() Initializes a new instance of the StyledElement class.

Events

Name Type Summary
AttachedToLogicalTree EventHandler<LogicalTreeAttachmentEventArgs>
Raised when the styled element is attached to a rooted logical tree.
DataContextChanged EventHandler
Occurs when the DataContext property changes.
DetachedFromLogicalTree EventHandler<LogicalTreeAttachmentEventArgs>
Raised when the styled element is detached from a rooted logical tree.
Initialized EventHandler
Occurs when the styled element has finished initialization.
PropertyChanged EventHandler<AvaloniaPropertyChangedEventArgs>
Raised when a AvaloniaProperty value changes on this object.
Inherited from AvaloniaObject
ResourcesChanged EventHandler<ResourcesChangedEventArgs>
Occurs when a resource in this styled element or a parent styled element has changed.

Fields

Name Constant Value Summary
ClockProperty
Inherited from Animatable
static
DataContextProperty
Defines the DataContext property.
static
NameProperty
Defines the Name property.
static
ParentProperty
Defines the Parent property.
static
TemplatedParentProperty
Defines the TemplatedParent property.
static
TransitionsProperty
Defines the Transitions property.
Inherited from Animatable
static

Properties

Name Value Summary
Classes Classes
Gets or sets the styled element's classes.
Clock IClock
Inherited from Animatable
DataContext object
Gets or sets the control's data context.
InheritanceParent IAvaloniaObject
Gets or sets the parent object that inherited AvaloniaProperty values are inherited from.
Inherited from AvaloniaObject
IsInitialized bool
Gets a value that indicates whether the element has finished initialization.
LogicalChildren IAvaloniaList<ILogical>
Gets the styled element's logical children.
Name string
Gets or sets the name of the styled element.
Parent IStyledElement
Gets the styled element's logical parent.
PseudoClasses IPseudoClasses
Gets the Classes collection in a form that allows adding and removing pseudoclasses.
Resources IResourceDictionary
Gets or sets the styled element's resource dictionary.
Styles Styles
Gets the styles for the styled element.
TemplatedParent ITemplatedControl
Gets the styled element whose lookless template this styled element is part of.
this[AvaloniaProperty] object
Gets or sets the value of a AvaloniaProperty.
Inherited from AvaloniaObject
this[IndexerDescriptor] IBinding
Gets or sets a binding for a AvaloniaProperty.
Inherited from AvaloniaObject
Transitions Transitions
Gets or sets the property transitions for the control.
Inherited from Animatable

Methods

Name Value Summary
AffectsValidation(AvaloniaProperty, AvaloniaProperty[]) void
Forces revalidation of properties when a property value changes.
Inherited from AvaloniaObject
static
BeginInit() void
Bind(AvaloniaProperty, IObservable<object>, BindingPriority) IDisposable
Binds a AvaloniaProperty to an observable.
Inherited from AvaloniaObject
Bind<T>(AvaloniaProperty<T>, IObservable<T>, BindingPriority) IDisposable
Binds a AvaloniaProperty to an observable.
Inherited from AvaloniaObject
CheckAccess() bool
Inherited from AvaloniaObject
ClearValue(AvaloniaProperty) void
Clears a AvaloniaProperty's local value.
Inherited from AvaloniaObject
EndInit() void
GetValue(AvaloniaProperty) object
Gets a AvaloniaProperty value.
Inherited from AvaloniaObject
GetValue<T>(AvaloniaProperty<T>) T
Gets a AvaloniaProperty value.
Inherited from AvaloniaObject
InitializeIfNeeded() void
IsAnimating(AvaloniaProperty) bool
Checks whether a AvaloniaProperty is animating.
Inherited from AvaloniaObject
IsSet(AvaloniaProperty) bool
Checks whether a AvaloniaProperty is set on this object.
Inherited from AvaloniaObject
OnAttachedToLogicalTree(LogicalTreeAttachmentEventArgs) void
Called when the styled element is added to a rooted logical tree.
OnDataContextBeginUpdate() void
Called when the DataContext begins updating.
OnDataContextChanged(EventArgs) void
Called when the DataContext property changes.
OnDataContextEndUpdate() void
Called when the DataContext finishes updating.
OnDetachedFromLogicalTree(LogicalTreeAttachmentEventArgs) void
Called when the styled element is removed from a rooted logical tree.
OnPropertyChanged(AvaloniaPropertyChangedEventArgs) void
Reacts to a change in a AvaloniaProperty value in order to animate the change if a ITransition is set for the property.
Inherited from Animatable
PseudoClass(AvaloniaProperty<bool>, string) void
Adds a pseudo-class to be set when a property is true.
static
PseudoClass<TOwner, TProperty>(AvaloniaProperty<TProperty>, Func<TProperty, bool>, string) void
Adds a pseudo-class to be set when a property equals a certain value.
static
PseudoClass<TOwner>(AvaloniaProperty<bool>, string) void
Adds a pseudo-class to be set when a property is true.
static
PseudoClass<TProperty>(AvaloniaProperty<TProperty>, Func<TProperty, bool>, string) void
Adds a pseudo-class to be set when a property equals a certain value.
static
RaisePropertyChanged(AvaloniaProperty, object, object, BindingPriority) void
Raises the PropertyChanged event.
Inherited from AvaloniaObject
Revalidate(AvaloniaProperty) void
Forces the specified property to be revalidated.
Inherited from AvaloniaObject
SetAndRaise<T>(AvaloniaProperty<T>, T, AvaloniaObject.SetAndRaiseCallback<T>, T) bool
Sets the backing field for a direct avalonia property, raising the PropertyChanged event if the value has changed.
Inherited from AvaloniaObject
SetAndRaise<T>(AvaloniaProperty<T>, T, T) bool
Sets the backing field for a direct avalonia property, raising the PropertyChanged event if the value has changed.
Inherited from AvaloniaObject
SetValue(AvaloniaProperty, object, BindingPriority) void
Sets a AvaloniaProperty value.
Inherited from AvaloniaObject
SetValue<T>(AvaloniaProperty<T>, T, BindingPriority) void
Sets a AvaloniaProperty value.
Inherited from AvaloniaObject
UpdateDataValidation(AvaloniaProperty, BindingNotification) void
Called to update the validation state for properties for which data validation is enabled.
Inherited from AvaloniaObject
VerifyAccess() void
Inherited from AvaloniaObject

Extension Methods

Name Value Summary
Bind(AvaloniaProperty, IBinding, object) IDisposable
Binds a property on an IAvaloniaObject to an IBinding.
FindNameScope() INameScope
FindResource(string) object
Finds the specified resource by searching up the logical tree and then global styles.
GetDiagnostic(AvaloniaProperty) AvaloniaPropertyValue
Gets a diagnostic for a AvaloniaProperty on a AvaloniaObject.
GetLogicalAncestors() IEnumerable<ILogical>
GetLogicalChildren() IEnumerable<ILogical>
GetLogicalDescendants() IEnumerable<ILogical>
GetLogicalParent() ILogical
GetLogicalParent<T>() T
GetLogicalSiblings() IEnumerable<ILogical>
GetObservable(AvaloniaProperty) IObservable<object>
Gets an observable for a AvaloniaProperty.
GetObservable<T>(AvaloniaProperty<T>) IObservable<T>
Gets an observable for a AvaloniaProperty.
GetPropertyChangedObservable(AvaloniaProperty) IObservable<AvaloniaPropertyChangedEventArgs>
Gets an observable that listens for property changed events for an AvaloniaProperty.
GetResourceObservable(string) IObservable<object>
GetSelfAndLogicalAncestors() IEnumerable<ILogical>
GetSelfAndLogicalDescendants() IEnumerable<ILogical>
GetSubject(AvaloniaProperty, BindingPriority) ISubject<object>
Gets a subject for a AvaloniaProperty.
GetSubject<T>(AvaloniaProperty<T>, BindingPriority) ISubject<T>
Gets a subject for a AvaloniaProperty.
IsLogicalParentOf(ILogical) bool
TryFindResource(string, object) bool
Tries to the specified resource by searching up the logical tree and then global styles.