Table of Contents

Class ResourceProvider

Namespace
Avalonia.Controls
Assembly
Avalonia.Base.dll

Base implementation for IResourceProvider interface. Includes Owner property management.

public abstract class ResourceProvider : AvaloniaObject, INotifyPropertyChanged, IResourceProvider, IResourceNode
Inheritance
ResourceProvider
Implements
Derived
Inherited Members
Extension Methods

Constructors

ResourceProvider()

public ResourceProvider()

ResourceProvider(IResourceHost)

public ResourceProvider(IResourceHost owner)

Parameters

owner IResourceHost

Properties

HasResources

Gets a value indicating whether the object has resources.

public abstract bool HasResources { get; }

Property Value

bool

Owner

Gets the owner of the resource provider.

public IResourceHost? Owner { get; }

Property Value

IResourceHost

Remarks

If multiple owners are added, returns the first.

Methods

OnAddOwner(IResourceHost)

Handles when owner was added. Base method implementation raises NotifyHostedResourcesChanged(ResourcesChangedEventArgs), if this provider has any resources.

protected virtual void OnAddOwner(IResourceHost owner)

Parameters

owner IResourceHost

New owner.

OnRemoveOwner(IResourceHost)

Handles when owner was removed. Base method implementation raises NotifyHostedResourcesChanged(ResourcesChangedEventArgs), if this provider has any resources.

protected virtual void OnRemoveOwner(IResourceHost owner)

Parameters

owner IResourceHost

Old owner.

RaiseResourcesChanged()

protected void RaiseResourcesChanged()

TryGetResource(object, ThemeVariant?, out object?)

Tries to find a resource within the object.

public abstract bool TryGetResource(object key, ThemeVariant? theme, out object? value)

Parameters

key object

The resource key.

theme ThemeVariant

Theme used to select theme dictionary.

value object

When this method returns, contains the value associated with the specified key, if the key is found; otherwise, null.

Returns

bool

True if the resource if found, otherwise false.

Events

OwnerChanged

Raised when the Owner of the resource provider changes.

public event EventHandler? OwnerChanged

Event Type

EventHandler