Triggerable Resource Bindings

Hey Fusers Crew,

It would be very convenient if we could change the Default Value of a Global Resource binding upon triggers … as such:

<App>
    <float4 ux:Global="MyApp.ThemeColor" ux:Value="Green" />

    <Navigator>
        <HomePage ux:Template="homePage" />
        <ProfilePage ux:Template="profilePage" />
        <SettingsPage ux:Template="settingsPage">

           <WhileTrue Value="{changeIt}">
              <float4 ux:Key="MyApp.ThemeColor" ux:Value="Blue" />
           </WhileTrue>

        </SettingsPage>
    </Navigator>
</App>

Please Consider my suggestion!

Cheers,

Elizabeth

1 Like

You can’t do this with globals, which are meant to be constant values, but you can do this with resources. Normally you’d use ux:Key to define a resource, but if you intend on changing it you need a resource setter:

<ResourceFloat4 Key="MyApp.ThemeColor" Value="0,1,0,1" ux:Name="themeColor"/>

You use this color with a normal resource binding Color="{Resource MyApp.ThemeColor}", To change it you can then use your animatior:

<Change Target="themeColor.Value" Value="0,0,1,1"/>

If you are spanning across many pages you might instead bind it to a JS export:

<ResourceFloat4 Key="MyApp.ThemeColor" Value="{themeColor}"/>
1 Like