Share via


ResourceDictionary.AddFactory Method

Definition

Overloads

Name Description
AddFactory(String, Func<Object>, Boolean)

Adds a resource factory to the dictionary. The factory is invoked lazily when the resource is first accessed.

AddFactory(Type, Func<Style>, Boolean)

Adds an implicit style factory to the dictionary. The factory is invoked lazily when the style is first accessed.

AddFactory(String, Func<Object>, Boolean)

Source:
ResourceDictionary.cs

Adds a resource factory to the dictionary. The factory is invoked lazily when the resource is first accessed.

public void AddFactory(string key, Func<object> factory, bool shared = true);
member this.AddFactory : string * Func<obj> * bool -> unit
Public Sub AddFactory (key As String, factory As Func(Of Object), Optional shared As Boolean = true)

Parameters

key
String

The resource key.

factory
Func<Object>

A factory function that creates the resource.

shared
Boolean

If true (default), the factory result is cached. If false, the factory is invoked on each access.

Applies to

AddFactory(Type, Func<Style>, Boolean)

Source:
ResourceDictionary.cs

Adds an implicit style factory to the dictionary. The factory is invoked lazily when the style is first accessed.

public void AddFactory(Type targetType, Func<Microsoft.Maui.Controls.Style> factory, bool shared = true);
member this.AddFactory : Type * Func<Microsoft.Maui.Controls.Style> * bool -> unit
Public Sub AddFactory (targetType As Type, factory As Func(Of Style), Optional shared As Boolean = true)

Parameters

targetType
Type

The target type for the implicit style. The type's full name is used as the key.

factory
Func<Style>

A factory function that creates the style.

shared
Boolean

If true (default), the factory result is cached. If false, the factory is invoked on each access.

Applies to