StaticResource Markup Extension
Provides a value for any XAML property attribute by evaluating a reference to an already defined resource.
XAML Attribute Usage
<object property="{StaticResource key}" .../>
XAML Values
| key | The key for the requested resource. This key is initially assigned by the A resource key can be any string defined in the |
| Important Note: |
|---|
| A StaticResource must not attempt to make a forward reference to a resource that is defined lexically further within the XAML file. Attempting to do so is not supported, and even if such a reference does not fail, attempting the forward reference incurs a load-time performance penalty when the internal hash tables representing a |
Attempting to specify a StaticResource to a key that cannot resolve results in a XAML parse exception.
In the Silverlight XAML processor implementation, there is no backing class representation. StaticResource is exclusively for use in XAML, using the {} syntax that indicates to a XAML processor that the contents should be treated by a markup extension. The equivalent code would involve querying a discrete
StaticResource cannot be used for an event attribute. Event handlers cannot be declared as resources. Event handlers referenced as event attribute values are referenced by their member name as defined in the partial class that provides code-behind for a XAML page, and resources are not involved here.
StaticResource 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.

Comments
Join the conversation! Your thoughts help the community grow.