Application Class

Summary

Encapsulates a Avalonia application.
graph BT Type-->Base0["AvaloniaObject"] click Base0 "/api/Avalonia/AvaloniaObject" Base0-->Base1["object"] Type-.->Interface0["IAvaloniaObjectDebug"] click Interface0 "/api/Avalonia.Diagnostics/IAvaloniaObjectDebug" Type-.->Interface1["INotifyPropertyChanged"] Type-.->Interface2["IDataContextProvider"] click Interface2 "/api/Avalonia/IDataContextProvider" Type-.->Interface3["IAvaloniaObject"] click Interface3 "/api/Avalonia/IAvaloniaObject" Type-.->Interface4["IGlobalDataTemplates"] click Interface4 "/api/Avalonia.Controls/IGlobalDataTemplates" Type-.->Interface5["IDataTemplateHost"] click Interface5 "/api/Avalonia.Controls.Templates/IDataTemplateHost" Type-.->Interface6["IGlobalStyles"] click Interface6 "/api/Avalonia.Styling/IGlobalStyles" Type-.->Interface7["IStyleRoot"] click Interface7 "/api/Avalonia.Styling/IStyleRoot" Type-.->Interface8["IStyleHost"] click Interface8 "/api/Avalonia.Styling/IStyleHost" Type-.->Interface9["IResourceNode"] click Interface9 "/api/Avalonia.Controls/IResourceNode" Type-.->Interface10["IResourceProvider"] click Interface10 "/api/Avalonia.Controls/IResourceProvider" Type["Application"] class Type type-node

Syntax

public class Application : AvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged, 
    IDataContextProvider, IAvaloniaObject, IGlobalDataTemplates, IDataTemplateHost, IGlobalStyles, 
    IStyleRoot, IStyleHost, IResourceNode, IResourceProvider

Remarks

The Application class encapsulates Avalonia application-specific functionality, including: - A global set of DataTemplates. - A global set of Styles. - A FocusManager. - An InputManager. - Registers services needed by the rest of Avalonia in the RegisterServices() method. - Tracks the lifetime of the application.

Constructors

Name Summary
Application() Creates an instance of the Application class.

Events

Name Type Summary
PropertyChanged EventHandler<AvaloniaPropertyChangedEventArgs>
Raised when a AvaloniaProperty value changes on this object.
Inherited from AvaloniaObject
ResourcesChanged EventHandler<ResourcesChangedEventArgs>
Raised when resources in the provider are changed.

Fields

Name Constant Value Summary
DataContextProperty
Defines the DataContext property.
static
NameProperty
Defines Name property
static

Properties

Name Value Summary
ApplicationLifetime IApplicationLifetime
Application lifetime, use it for things like setting the main window and exiting the app from code Currently supported lifetimes are: - IClassicDesktopStyleApplicationLifetime - ISingleViewApplicationLifetime - IControlledApplicationLifetime
Clipboard IClipboard
Gets the application clipboard.
Current Application
Gets the current instance of the Application class.
static
DataContext object
Gets or sets the Applications's data context.
DataTemplates DataTemplates
Gets or sets the application's global data templates.
FocusManager IFocusManager
Gets the application's focus manager.
InheritanceParent IAvaloniaObject
Gets or sets the parent object that inherited AvaloniaProperty values are inherited from.
Inherited from AvaloniaObject
InputManager InputManager
Gets the application's input manager.
Name string
Application name to be used for various platform-specific purposes
Resources IResourceDictionary
Gets the application's global resource dictionary.
Styles Styles
Gets the application's global styles.
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

Methods

Name Value Summary
AffectsValidation(AvaloniaProperty, AvaloniaProperty[]) void
Forces revalidation of properties when a property value changes.
Inherited from AvaloniaObject
static
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
Equals(object) bool
Compares two objects using reference equality.
Inherited from AvaloniaObject
GetHashCode() int
Gets the hash code for the object.
Inherited from AvaloniaObject
GetValue(AvaloniaProperty) object
Gets a AvaloniaProperty value.
Inherited from AvaloniaObject
GetValue<T>(AvaloniaProperty<T>) T
Gets a AvaloniaProperty value.
Inherited from AvaloniaObject
Initialize() void
Initializes the application by loading XAML etc.
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
OnFrameworkInitializationCompleted() void
OnPropertyChanged(AvaloniaPropertyChangedEventArgs) void
Called when a avalonia property changes on the object.
Inherited from AvaloniaObject
RegisterServices() void
Register's the services needed by Avalonia.
Revalidate(AvaloniaProperty) void
Forces the specified property to be revalidated.
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.
FindResource(object) 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.
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(object) IObservable<object>
GetSubject(AvaloniaProperty, BindingPriority) ISubject<object>
Gets a subject for a AvaloniaProperty.
GetSubject<T>(AvaloniaProperty<T>, BindingPriority) ISubject<T>
Gets a subject for a AvaloniaProperty.
Run() void
Run(CancellationToken) void
On desktop-style platforms runs the application's main loop with custom CancellationToken without setting a lifetime.
Run(ICloseable) void
On desktop-style platforms runs the application's main loop until closable is closed
Run(Window) void
On desktop-style platforms runs the application's main loop until main window is closed
RunWithMainWindow<TWindow>() void
TryFindResource(object, object) bool
Tries to the specified resource by searching up the logical tree and then global styles.