MattNiznak
Topic Author
Posts: 8
Joined: 14 Oct 2019, 10:17

Preload resource dictionary and change resource dictionary at runtime.

21 Oct 2020, 13:59

I'm still on Noesis 2.2.

The method I'm using for loading elements is that elements are dynamically generated based on other data... so elements have their own XAML and are loaded without hierarchy. They are then attached to a parent. If I load this way, they load before parented and don't inherit the resource dictionary of their parent.

I could add the resource dictionary file to every element xaml, but then there is a significant slowdown as each element loads their own copy of the resource dictionary. I want to be able to load resource dictionary at the start of the program and attach it to elements later. I've tried using the SetResource() function, but that doesn't seem to change anything. I was wondering if I was missing something.
 
User avatar
sfernandez
Site Admin
Posts: 2997
Joined: 22 Dec 2011, 19:20

Re: Preload resource dictionary and change resource dictionary at runtime.

21 Oct 2020, 16:40

I want to be able to load resource dictionary at the start of the program and attach it to elements later.
You should use the Application Resources, a global dictionary loaded at application startup that is accessed by all the xamls you load later: https://www.noesisengine.com/docs/Gui.C ... -resources
Elements have their own XAML and are loaded without hierarchy. They are then attached to a parent. If I load this way, they load before parented and don't inherit the resource dictionary of their parent.
This is because you are probably using StaticResources, that resolve when xaml is parsed. If you use DynamicResource then they will update when connected to a different parent.

Who is online

Users browsing this forum: Dmirty, Google [Bot] and 4 guests