A resource dictionary is a collection of resource IDs pointing to resources. By default resource dictionaries are present in the root nodes of all prefabs but you can add a resource dictionary to any node.
A node can access all resource IDs in its own resource dictionary and in resource dictionaries defined in its ascendant nodes. You can assign resource IDs as values for resource properties and they are shown in Kanzi Studio with the syntax RscID → Resource.
You can make resources local to any node. By adding a resource to a scope of a node you add a resource ID entry to the resource dictionary of that node. A resource ID is an identifier that abstracts a resource from where it is used.
To add a resource dictionary to a node, in the Project press Alt and right-click a node and select Resource Dictionary.
To view the content of a resource dictionary:
To view and activate locales and themes, in the Dictionaries click Locales and Themes to enable the viewing of localization tables and theme groups, and for each localization table and theme group select the locale and theme you want to see in the Preview.
To add a resource to a resource dictionary:
You can use a kzb URL to point to resources in another Kanzi Studio project.
To use a kzb URL for a resource in a resource dictionary:
To create a resource dictionary:
// Create a resource dictionary. ResourceDictionarySharedPtr dictionary = ResourceDictionary::create(domain, "Dictionary");
To add content to a resource dictionary:
// Add resources to a resource dictionary. dictionary->add(ResourceID("red icon"), texture); dictionary->add(ResourceID("blue icon"), "kzb://my_project/Textures/Blue Icon");
To get resources from a resource dictionary:
// Acquire resources from a resource dictionary. ResourceSharedPtr redIcon = dictionary->acquire(ResourceID("red icon")); ResourceSharedPtr blueIcon = dictionary->acquire(ResourceID("blue icon"));
To change the resource dictionary of a node:
// Change the resource dictionary of a node. node->setResourceDictionary(dictionary);
To extend the existing resource dictionary of a node:
// Extend the existing resource dictionary of a node with a nested resource dictionary. node->addResourceDictionary(dictionary);
For details, see the ResourceDictionary
class in the API reference.