Page 1 of 1

Loading a Resource Dictionary programmatically.

Posted: 27 Jan 2021, 22:09
by riacosta
I'm trying to load a resource dictionary from code. I've tried using GUI.LoadXaml(path) and GUI.LoadXamlResource(path) but I can't even getto pass a path that finds the resource.
Do you guys have an example of this by any chance?

Re: Loading a Resource Dictionary programmatically.

Posted: 01 Feb 2021, 17:43
by sfernandez
We use that in our Localization sample:
Resources = (ResourceDictionary)Noesis.GUI.LoadXaml("Assets/NoesisGUI/Samples/Localization/Language-en.xaml")
But make sure that the xaml dictionary is referenced from any other loaded asset. You can do that by explicitly adding a dependency in one of your root xamls:
<noesis:Xaml.Dependencies>
  <noesis:Dependency Source="Language-en.xaml"/>
</noesis:Xaml.Dependencies>