Partager via


IXRResourceDictionary (Windows Embedded CE 6.0)

1/6/2010

This class provides a dictionary that contains keyed resources used by components of a Silverlight–based application.

Syntax

class IXRResourceDictionary : public IXRDependencyObject

Methods

Method Description

IXRResourceDictionary::Add

Adds an item to the resource dictionary.

IXRResourceDictionary::Clear

Removes all items from this resource dictionary.

IXRResourceDictionary::Contains

Determines whether this resource dictionary contains the item that has the specified key name.

IXRResourceDictionary::GetCount

Retrieves the number of items that are contained in the resource dictionary.

IXRResourceDictionary::GetItem

Retrieves the item with the specified key name.

IXRResourceDictionary::Remove

Removes a specific item from the resource dictionary.

Remarks

A resource dictionary is a keyed dictionary of objects that can be defined both in XAML and in C++ code. XAML is the most common usage, particularly for initially defining objects in a resource dictionary. Resource dictionaries can exist at several positions in an application structure, including as application-scope resources that belong to IXRApplication, as immediate resources for any object that inherits from IXRFrameworkElement, or as XAML files that are kept separate and unloaded in the application structure for later run-time use.

Resource dictionaries commonly support two major scenarios: defining templates for controls, and defining storyboards for animated properties. For example, an IXRControlTemplate object can be defined as a resource if it is included as an item in a resource dictionary belonging to an object. Or, an IXRStoryboard object can be defined as a resource of a specific object if it is included in the resource dictionary for an object.

This object type is used by the IXRFrameworkElement::GetResources method. You can obtain a pointer to an IXRResourceDictionary object for a UI element by calling the inherited method IXRFrameworkElement::GetResources for an object derived from IXRFrameworkElement. Then, you can use the methods inherited from IXRCollection<In_T, Out_T> to add items, remove items, or clear the complete collection. These items will usually be either IXRStoryboard objects or an IXRControlTemplate object.

This object type is also used by the IXRApplication::GetResourceDictionary method. You can obtain a pointer to an IXRResourceDictionary object for the application by calling the method IXRApplication::GetResourceDictionary.

You can define a resource dictionary in Microsoft Silverlight 2 XAML. For information about the differences between XAML in Silverlight for Windows Embedded and Silverlight 2, see Differences Between Silverlight for the Web and Silverlight for Windows Embedded. For more information about how to define this element in the source XAML for your application, see this Microsoft Web site.

The items contained by IXRResourceDictionary must each have a key defined. You can define a key in the source XAML for your application, by providing a value for the x:Key attribute on the object element that is added as <ResourceDictionary> content. Or, you can define a key when you call IXRResourceDictionary::Add. If x:Key is not specified, the x:Name is used as the key. For more information about using these attributes in Microsoft Silverlight 2 XAML, see "Keys and Resources" and "Referencing Resources from XAML" at this Microsoft Web site.

If an x:Name or x:Key was defined in source XAML, you can locate an object in a resource dictionary from C++ code after the XAML is parsed into an object tree. To do this, call the method IXRResourceDictionary::GetItem.

Inheritance Hierarchy

IXRDependencyObject

     IXRResourceDictionary

.NET Framework Equivalent

System.Windows.ResourceDictionary

Requirements

Header XamlRuntime.h
sysgen SYSGEN_XAML_RUNTIME
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

Classes for Collection Management