Provides a value for any XAML property attribute by evaluating a reference to an already defined resource.
<object property="{StaticResource key}" .../>
key
The key for the requested resource. This key is initially assigned by the x:Key attribute on an object element if a resource was created in markup, or was provided as the key parameter when calling Add if the resource was created in code.
A resource key can be any string defined in the XamlName Grammar.
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 ResourceDictionary are searched. For best results, adjust the composition of your resource dictionaries such that forward references can be avoided.
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 ResourceDictionary, using the Contains API.
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.