CustomResource markup extension (Windows Store apps using C#/VB/C++ and XAML)

1 out of 1 rated this helpful - Rate this topic

Provides a value for any XAML attribute by evaluating a reference to a resource that comes from a custom resource-lookup implementation. Resource lookup is performed by a CustomXamlResourceLoader class implementation.

XAML attribute usage

<object property="{CustomResource key}" .../>

XAML values

TermDescription

key

The key for the requested resource. How the key is initially assigned is specific to the implementation of the CustomXamlResourceLoader class that is currently registered for use.

 

Remarks

CustomResource is a technique for obtaining values that are defined elsewhere in a custom resource repository. This technique is relatively advanced and isn't used by most Windows Store app built for Windows using C++, C#, or Visual Basic scenarios.

How a CustomResource resolves to a resource dictionary is not described in this topic, because that can vary widely depending on how CustomXamlResourceLoader is implemented.

The GetResource method of the CustomXamlResourceLoader implementation is called by the Windows Runtime XAML parser whenever it encounters a {CustomResource} usage in markup. The resourceId that is passed to GetResource comes from the key argument, and the other input parameters come from context, such as which property the usage is applied to.

CustomResource is a markup extension. Markup extensions are typically implemented when there is a requirement to escape attribute values to be other than literal values or handler names, and the requirement is more global than just putting type converters on certain types or properties. All markup extensions in XAML use the "{" and "}" characters in their attribute syntax, which is the convention by which a XAML processor recognizes that a markup extension must process the attribute.

Related topics

ResourceDictionary and StaticResource references
CustomXamlResourceLoader
GetResource

 

 

Build date: 11/28/2012

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.