Binds to a resource with the key provided in a context variable. This allows selecting resources from JavaScript by key name.

In this example three different fonts are created as resources. The font is selected by name in the exported JavaScript items.

<Font File="../../Assets/fonts/Roboto-Bold.ttf" ux:Key="Bold"/>
<Font File="../../Assets/fonts/Roboto-Regular.ttf" ux:Key="Regular"/>
<Font File="../../Assets/fonts/Roboto-Italic.ttf" ux:Key="Italic"/>

<JavaScript>
    exports.items = [
        { font: "Bold" },
        { font: "Regular" },
        { font: "Italic" },
    ]
</JavaScript>
<StackPanel>
    <Each Items="{items}">
        <Text Value="Sample Text" Font="{DataToResource font}"/>
    </Each>
</StackPanel>

{DataToResource variableKey} is similar to {Resource key}, except it allows a variable key name instead of a static one.

Location

Namespace
Fuse.Reactive
Package
Fuse.Reactive.Expressions 2.9.1
Show Uno properties and methods

Interface of DataToResource

Inherited from Expression

Inherited from object

Attached UX Attributes

GlobalKey (attached by Resource) : string ux

The ux:Global attribute creates a global resource that is accessible everywhere in UX markup.

Implemented Interfaces

See Also