# ResourceDictionary

Version: 0.5.0
Framework commit: d503df2befa756e681fcdc6250e9552dc7388bea
Canonical URL: /docs/0.5.0/api/ferroui-base/controls/struct-resourcedictionary/

**struct** · [`ferroui-base`](/docs/0.5.0/api/ferroui-base/) · v0.5.0

```rust
struct ResourceDictionary
```

An indexed dictionary of resources.

[View source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L142)

## Members

- [`TYPE`](#assoc_const-type)
- [`to_ref`](#function-to_ref)
- [`construct`](#function-construct)
- [`construct_with_owner`](#function-construct_with_owner)
- [`new`](#function-new)
- [`with_owner`](#function-with_owner)
- [`count`](#function-count)
- [`get`](#function-get)
- [`set`](#function-set)
- [`keys`](#function-keys)
- [`merged_dictionaries`](#function-merged_dictionaries)
- [`add_merged_dictionary`](#function-add_merged_dictionary)
- [`remove_merged_dictionary`](#function-remove_merged_dictionary)
- [`theme_dictionaries`](#function-theme_dictionaries)
- [`theme_dictionaries_snapshot`](#function-theme_dictionaries_snapshot)
- [`theme_dictionary`](#function-theme_dictionary)
- [`add_theme_dictionary`](#function-add_theme_dictionary)
- [`set_theme_dictionary`](#function-set_theme_dictionary)
- [`remove_theme_dictionary`](#function-remove_theme_dictionary)
- [`key`](#function-key)
- [`set_key`](#function-set_key)
- [`add`](#function-add)
- [`add_value`](#function-add_value)
- [`add_deferred_fn`](#function-add_deferred_fn)
- [`add_deferred`](#function-add_deferred)
- [`add_not_shared_deferred`](#function-add_not_shared_deferred)
- [`set_items`](#function-set_items)
- [`clear`](#function-clear)
- [`contains_key`](#function-contains_key)
- [`remove`](#function-remove)
- [`try_get_value`](#function-try_get_value)
- [`ensure_capacity`](#function-ensure_capacity)
- [`contains_deferred_key`](#function-contains_deferred_key)

<a id="assoc_const-type"></a>

### TYPE

```rust
const TYPE: &'static $crate::TypeInfo
```

The runtime type of this class.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L161)

<a id="function-to_ref"></a>

### to_ref

```rust
fn to_ref(self: &Self) -> $crate::Ref<ResourceDictionary>
```

Returns a strong reference to this object.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L161)

<a id="function-construct"></a>

### construct

```rust
fn construct() -> Self
```

Creates the class data; see `FerroObject::construct`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L286)

<a id="function-construct_with_owner"></a>

### construct_with_owner

```rust
fn construct_with_owner(owner: &ResourceHostRef) -> Self
```

Creates the class data of a dictionary that belongs to `owner`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L291)

<a id="function-new"></a>

### new

```rust
fn new() -> Ref<Self>
```

Creates an empty resource dictionary.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L296)

<a id="function-with_owner"></a>

### with_owner

```rust
fn with_owner(owner: impl Into<ResourceHostRef>) -> Ref<Self>
```

Creates an empty resource dictionary that belongs to `owner`.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L301)

<a id="function-count"></a>

### count

```rust
fn count(self: &Self) -> usize
```

The number of resources in the dictionary itself.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L306)

<a id="function-get"></a>

### get

```rust
fn get(self: &Self, key: &ResourceKey) -> ResourceValue
```

Gets a resource of the dictionary itself; `None` (a null value) if the
key is not present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L312)

<a id="function-set"></a>

### set

```rust
fn set(self: &Self, key: impl Into<ResourceKey>, value: ResourceValue)
```

Adds or replaces a resource.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L317)

<a id="function-keys"></a>

### keys

```rust
fn keys(self: &Self) -> Vec<ResourceKey>
```

The keys of the resources in the dictionary itself.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L325)

<a id="function-merged_dictionaries"></a>

### merged_dictionaries

```rust
fn merged_dictionaries(self: &Self) -> FerroList<Rc<dyn IResourceProvider>>
```

The child resource dictionaries.

The list is returned by handle: clones refer to the same list.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L332)

<a id="function-add_merged_dictionary"></a>

### add_merged_dictionary

```rust
fn add_merged_dictionary(self: &Self, provider: impl Into<Rc<dyn IResourceProvider>>)
```

Adds a child resource dictionary.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L375)

<a id="function-remove_merged_dictionary"></a>

### remove_merged_dictionary

```rust
fn remove_merged_dictionary(self: &Self, provider: &Rc<dyn IResourceProvider>) -> bool
```

Removes a child resource dictionary. Returns whether it was present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L380)

<a id="function-theme_dictionaries"></a>

### theme_dictionaries

```rust
fn theme_dictionaries(self: &Self) -> FerroDictionary<ThemeVariant, Rc<dyn IThemeVariantProvider>>
```

The resource providers used for specific theme variants.

The dictionary is returned by handle: clones refer to the same
dictionary. A provider added to it gets the owner of this dictionary;
a removed one loses it.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L397)

<a id="function-theme_dictionaries_snapshot"></a>

### theme_dictionaries_snapshot

```rust
fn theme_dictionaries_snapshot(self: &Self) -> Vec<(ThemeVariant, Rc<dyn IThemeVariantProvider>)>
```

A snapshot of the resource providers used for specific theme variants.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L436)

<a id="function-theme_dictionary"></a>

### theme_dictionary

```rust
fn theme_dictionary(self: &Self, variant: &ThemeVariant) -> Option<Rc<dyn IThemeVariantProvider>>
```

The resource provider used for the given theme variant.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L444)

<a id="function-add_theme_dictionary"></a>

### add_theme_dictionary

```rust
fn add_theme_dictionary(self: &Self, variant: ThemeVariant, provider: impl Into<Rc<dyn IThemeVariantProvider>>)
```

Adds a resource provider for a theme variant. Panics if the variant
already has one.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L450)

<a id="function-set_theme_dictionary"></a>

### set_theme_dictionary

```rust
fn set_theme_dictionary(self: &Self, variant: ThemeVariant, provider: impl Into<Rc<dyn IThemeVariantProvider>>)
```

Adds or replaces the resource provider of a theme variant.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L455)

<a id="function-remove_theme_dictionary"></a>

### remove_theme_dictionary

```rust
fn remove_theme_dictionary(self: &Self, variant: &ThemeVariant) -> bool
```

Removes the resource provider of a theme variant. Returns whether it
was present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L461)

<a id="function-key"></a>

### key

```rust
fn key(self: &Self) -> Option<ThemeVariant>
```

The key that is used in the theme dictionaries of the containing
resource dictionary.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L467)

<a id="function-set_key"></a>

### set_key

```rust
fn set_key(self: &Self, value: Option<ThemeVariant>)
```



[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L471)

<a id="function-add"></a>

### add

```rust
fn add(self: &Self, key: impl Into<ResourceKey>, value: ResourceValue)
```

Adds a resource. Panics if the key is already present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L476)

<a id="function-add_value"></a>

### add_value

```rust
fn add_value<T: PartialEq + 'static>(self: &Self, key: impl Into<ResourceKey>, value: T)
```

Adds a resource value. Panics if the key is already present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L481)

<a id="function-add_deferred_fn"></a>

### add_deferred_fn

```rust
fn add_deferred_fn(self: &Self, key: impl Into<ResourceKey>, factory: impl Fn(Option<&Rc<dyn IServiceProvider>>) -> Option<BoxedValue> + 'static)
```

Adds a resource that is created by `factory` the first time it is
requested.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L499)

<a id="function-add_deferred"></a>

### add_deferred

```rust
fn add_deferred(self: &Self, key: impl Into<ResourceKey>, deferred_content: Rc<dyn IDeferredContent>)
```

Adds a resource that is built from `deferred_content` the first time
it is requested.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L509)

<a id="function-add_not_shared_deferred"></a>

### add_not_shared_deferred

```rust
fn add_not_shared_deferred(self: &Self, key: impl Into<ResourceKey>, deferred_content: Rc<dyn IDeferredContent>)
```

Adds a resource that is built from `deferred_content` every time it is
requested.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L523)

<a id="function-set_items"></a>

### set_items

```rust
fn set_items(self: &Self, values: impl IntoIterator<Item = (ResourceKey, ResourceValue)>)
```

Adds or replaces multiple resources, raising a single notification.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L528)

<a id="function-clear"></a>

### clear

```rust
fn clear(self: &Self)
```

Removes all resources of the dictionary itself.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L540)

<a id="function-contains_key"></a>

### contains_key

```rust
fn contains_key(self: &Self, key: &ResourceKey) -> bool
```

Whether the dictionary itself contains the key.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L558)

<a id="function-remove"></a>

### remove

```rust
fn remove(self: &Self, key: &ResourceKey) -> bool
```

Removes a resource. Returns whether it was present.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L563)

<a id="function-try_get_value"></a>

### try_get_value

```rust
fn try_get_value(self: &Self, key: &ResourceKey) -> Option<ResourceValue>
```

Gets a resource of the dictionary itself, building it if it is
deferred.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L575)

<a id="function-ensure_capacity"></a>

### ensure_capacity

```rust
fn ensure_capacity(self: &Self, capacity: usize)
```

Ensures that the dictionary can hold up to `capacity` resources
without further expansion of its backing storage.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L626)

<a id="function-contains_deferred_key"></a>

### contains_deferred_key

```rust
fn contains_deferred_key(self: &Self, key: &ResourceKey) -> bool
```

Whether the key is present and its resource has not been built yet.

[Source](https://github.com/wieslawsoltes/FerroUI/blob/d503df2befa756e681fcdc6250e9552dc7388bea/src/FerroUI.Base/controls/resource_dictionary.rs#L633)

## Trait implementations

- `Send`
- `Sync`
- `Freeze`
- `UnsafeUnpin`
- `Unpin`
- `UnwindSafe`
- `RefUnwindSafe`
- [`ResourceProviderImplExt`](/docs/0.5.0/api/ferroui-base/controls/trait-resourceproviderimplext/)
- [`FerroObjectImplExt`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimplext/)
- [`ClassDefaults`](/docs/0.5.0/api/ferroui-base/trait-classdefaults/)
- `Borrow<T>`
- `BorrowMut<T>`
- `Into<U>`
- `From<T>`
- `TryInto<U>`
- `TryFrom<U>`
- [`Receiver`](/docs/0.5.0/api/ferroui-system/task/oneshot/struct-receiver/)
- `Any`
- `ErasedDestructor`
- `IntoEither`
- `Deref`
- [`Upcast<T>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`Upcast<ResourceDictionary>`](/docs/0.5.0/api/ferroui-base/trait-upcast/)
- [`StaticType`](/docs/0.5.0/api/ferroui-base/trait-statictype/)
- [`ObjectType`](/docs/0.5.0/api/ferroui-base/trait-objecttype/)
- [`Subclassable<T>`](/docs/0.5.0/api/ferroui-base/trait-subclassable/)
- [`DefaultConstructible`](/docs/0.5.0/api/ferroui-base/trait-defaultconstructible/)
- [`FerroObjectImpl`](/docs/0.5.0/api/ferroui-base/trait-ferroobjectimpl/)
- [`ResourceProviderImpl`](/docs/0.5.0/api/ferroui-base/controls/trait-resourceproviderimpl/)

## Availability

Extracted for `aarch64-apple-darwin`. Cargo features are listed in the [crate index](/docs/0.5.0/api/).
