Table of Contents

Class ResourceDictionary

Namespace
Avalonia.Controls
Assembly
Avalonia.Base.dll

An indexed dictionary of resources.

public class ResourceDictionary : ResourceProvider, INotifyPropertyChanged, IResourceDictionary, IDictionary<object, object?>, ICollection<KeyValuePair<object, object?>>, IEnumerable<KeyValuePair<object, object?>>, IEnumerable, IThemeVariantProvider, IResourceProvider, IResourceNode
Inheritance
ResourceDictionary
Implements
Derived
Inherited Members
Extension Methods

Constructors

ResourceDictionary()

Initializes a new instance of the ResourceDictionary class.

public ResourceDictionary()

ResourceDictionary(IResourceHost)

Initializes a new instance of the ResourceDictionary class.

public ResourceDictionary(IResourceHost owner)

Parameters

owner IResourceHost

Properties

Count

public int Count { get; }

Property Value

int

HasResources

Gets a value indicating whether the object has resources.

public override sealed bool HasResources { get; }

Property Value

bool

this[object]

public object? this[object key] { get; set; }

Parameters

key object

Property Value

object

Keys

public ICollection<object> Keys { get; }

Property Value

ICollection<object>

MergedDictionaries

Gets a collection of child resource dictionaries.

public IList<IResourceProvider> MergedDictionaries { get; }

Property Value

IList<IResourceProvider>

ThemeDictionaries

Gets a collection of merged resource dictionaries that are specifically keyed and composed to address theme scenarios.

public IDictionary<ThemeVariant, IThemeVariantProvider> ThemeDictionaries { get; }

Property Value

IDictionary<ThemeVariant, IThemeVariantProvider>

Values

public ICollection<object?> Values { get; }

Property Value

ICollection<object>

Methods

Add(object, object?)

public void Add(object key, object? value)

Parameters

key object
value object

AddDeferred(object, IDeferredContent)

public void AddDeferred(object key, IDeferredContent deferredContent)

Parameters

key object
deferredContent IDeferredContent

AddDeferred(object, Func<IServiceProvider?, object?>)

public void AddDeferred(object key, Func<IServiceProvider?, object?> factory)

Parameters

key object
factory Func<IServiceProvider, object>

AddNotSharedDeferred(object, IDeferredContent)

public void AddNotSharedDeferred(object key, IDeferredContent deferredContent)

Parameters

key object
deferredContent IDeferredContent

Clear()

public void Clear()

ContainsKey(object)

public bool ContainsKey(object key)

Parameters

key object

Returns

bool

EnsureCapacity(int)

Ensures that the resource dictionary can hold up to capacity entries without any further expansion of its backing storage.

public void EnsureCapacity(int capacity)

Parameters

capacity int

Remarks

This method may have no effect when targeting .NET Standard 2.0.

GetEnumerator()

public IEnumerator<KeyValuePair<object, object?>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<object, object>>

OnAddOwner(IResourceHost)

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

protected override sealed 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 override sealed void OnRemoveOwner(IResourceHost owner)

Parameters

owner IResourceHost

Old owner.

Remove(object)

public bool Remove(object key)

Parameters

key object

Returns

bool

SetItems(IEnumerable<KeyValuePair<object, object?>>)

public void SetItems(IEnumerable<KeyValuePair<object, object?>> values)

Parameters

values IEnumerable<KeyValuePair<object, object>>

TryGetResource(object, ThemeVariant?, out object?)

Tries to find a resource within the object.

public override sealed 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.

TryGetValue(object, out object?)

public bool TryGetValue(object key, out object? value)

Parameters

key object
value object

Returns

bool