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["IValueSink"] Type-.->Interface3["IDataContextProvider"] click Interface3 "/api/Avalonia/IDataContextProvider" Type-.->Interface4["IAvaloniaObject"] click Interface4 "/api/Avalonia/IAvaloniaObject" Type-.->Interface5["IGlobalDataTemplates"] click Interface5 "/api/Avalonia.Controls/IGlobalDataTemplates" Type-.->Interface6["IDataTemplateHost"] click Interface6 "/api/Avalonia.Controls.Templates/IDataTemplateHost" Type-.->Interface7["IGlobalStyles"] click Interface7 "/api/Avalonia.Styling/IGlobalStyles" Type-.->Interface8["IStyleHost"] click Interface8 "/api/Avalonia.Styling/IStyleHost" Type-.->Interface9["IResourceHost"] click Interface9 "/api/Avalonia.Controls/IResourceHost" Type-.->Interface10["IResourceNode"] click Interface10 "/api/Avalonia.Controls/IResourceNode" Type-.->Interface11["IApplicationPlatformEvents"] click Interface11 "/api/Avalonia.Platform/IApplicationPlatformEvents" Type["Application"] class Type type-node

Syntax

public class Application : AvaloniaObject, IAvaloniaObjectDebug, INotifyPropertyChanged, 
    IValueSink, IDataContextProvider, IAvaloniaObject, IGlobalDataTemplates, IDataTemplateHost, 
    IGlobalStyles, IStyleHost, IResourceHost, IResourceNode, IApplicationPlatformEvents

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 the resources change on the element or an ancestor of the element.
UrlsOpened EventHandler<UrlOpenedEventArgs>

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
BeginBatchUpdate() void
Inherited from AvaloniaObject
Bind<T>(DirectPropertyBase<T>, IObservable<BindingValue<T>>) IDisposable
Binds a AvaloniaProperty to an observable.
Inherited from AvaloniaObject
Bind<T>(StyledPropertyBase<T>, IObservable<BindingValue<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
ClearValue<T>(AvaloniaProperty<T>) void
Clears a AvaloniaProperty's local value.
Inherited from AvaloniaObject
ClearValue<T>(DirectPropertyBase<T>) void
Clears a AvaloniaProperty's local value.
Inherited from AvaloniaObject
ClearValue<T>(StyledPropertyBase<T>) void
Clears a AvaloniaProperty's local value.
Inherited from AvaloniaObject
CoerceValue<T>(StyledPropertyBase<T>) void
Coerces the specified AvaloniaProperty.
Inherited from AvaloniaObject
EndBatchUpdate() void
Inherited from AvaloniaObject
Equals(object) bool
Compares two objects using reference equality.
Inherited from AvaloniaObject
GetBaseValue<T>(StyledPropertyBase<T>, BindingPriority) Optional<T>
Gets an AvaloniaProperty base value.
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>(DirectPropertyBase<T>) T
Gets a AvaloniaProperty value.
Inherited from AvaloniaObject
GetValue<T>(StyledPropertyBase<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
RegisterServices() void
Register's the services needed by Avalonia.
SetValue(AvaloniaProperty, object, BindingPriority) void
Sets a AvaloniaProperty value.
Inherited from AvaloniaObject
SetValue<T>(DirectPropertyBase<T>, T) void
Sets a AvaloniaProperty value.
Inherited from AvaloniaObject
SetValue<T>(StyledPropertyBase<T>, T, BindingPriority) IDisposable
Sets a AvaloniaProperty value.
Inherited from AvaloniaObject
VerifyAccess() void
Inherited from AvaloniaObject

Extension Methods

Name Value Summary
Bind(AvaloniaProperty, IObservable<BindingValue<object>>, BindingPriority) IDisposable
Binds a AvaloniaProperty to an observable.
Bind<T>(AvaloniaProperty<T>, IObservable<BindingValue<T>>, BindingPriority) IDisposable
Binds a AvaloniaProperty to an observable.
FindResource(object) object?
Finds the specified resource by searching up the logical tree and then global styles.
GetBindingObservable(AvaloniaProperty) IObservable<BindingValue<object>>
Gets an observable for a AvaloniaProperty.
GetBindingObservable<T>(AvaloniaProperty<T>) IObservable<BindingValue<T>>
Gets an observable for a AvaloniaProperty.
GetBindingSubject(AvaloniaProperty, BindingPriority) ISubject<BindingValue<object>>
Gets a subject for a AvaloniaProperty.
GetBindingSubject<T>(AvaloniaProperty<T>, BindingPriority) ISubject<BindingValue<T>>
Gets a subject for a AvaloniaProperty.
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, Func<object?, 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.