Class ResourceDictionary
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
HasResources
Gets a value indicating whether the object has resources.
public override sealed bool HasResources { get; }
Property Value
this[object]
public object? this[object key] { get; set; }
Parameters
key
object
Property Value
Keys
public ICollection<object> Keys { get; }
Property Value
MergedDictionaries
Gets a collection of child resource dictionaries.
public IList<IResourceProvider> MergedDictionaries { get; }
Property Value
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
Values
public ICollection<object?> Values { get; }
Property Value
Methods
Add(object, object?)
public void Add(object key, object? value)
Parameters
AddDeferred(object, IDeferredContent)
public void AddDeferred(object key, IDeferredContent deferredContent)
Parameters
key
objectdeferredContent
IDeferredContent
AddDeferred(object, Func<IServiceProvider?, object?>)
public void AddDeferred(object key, Func<IServiceProvider?, object?> factory)
Parameters
key
objectfactory
Func<IServiceProvider, object>
AddNotSharedDeferred(object, IDeferredContent)
public void AddNotSharedDeferred(object key, IDeferredContent deferredContent)
Parameters
key
objectdeferredContent
IDeferredContent
Clear()
public void Clear()
ContainsKey(object)
public bool ContainsKey(object key)
Parameters
key
object
Returns
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
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
IResourceHostNew 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
IResourceHostOld owner.
Remove(object)
public bool Remove(object key)
Parameters
key
object
Returns
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
objectThe resource key.
theme
ThemeVariantTheme used to select theme dictionary.
value
objectWhen 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)