--- title: XAML resources overview description: Learn what a Windows Presentation Foundation (WPF) resource is. WPF provides a resource system, both in XAML and in code, that allows to you create, reference, and reuse resources. author: adegeo ms.author: adegeo ms.date: 03/31/2021 ms.topic: overview dev_langs: - "csharp" - "vb" --- # Overview of XAML resources (WPF .NET) A resource is an object that can be reused in different places in your app. Examples of resources include brushes and styles. This overview describes how to use resources in Extensible Application Markup Language (XAML). You can also create and access resources by using code. > [!NOTE] > XAML resources described in this article are different from *app resources*, which are generally files added to an app, such as content, data, or embedded files. [!INCLUDE [desktop guide under construction](../../includes/desktop-guide-preview-note.md)] ## Use resources in XAML The following example defines a as a resource on the root element of a page. The example then references the resource and uses it to set properties of several child elements, including an , a , and a . :::code language="xaml" source="./snippets/xaml-resources-overview/csharp/ResExample.xaml"::: Every framework-level element ( or ) has a property, which is a type that contains defined resources. You can define resources on any element, such as a . However, resources are most often defined on the root element, which is in the example. Each resource in a resource dictionary must have a unique key. When you define resources in markup, you assign the unique key through the [x:Key Directive](../../../xaml-services/xkey-directive.md). Typically, the key is a string; however, you can also set it to other object types by using the appropriate markup extensions. Non-string keys for resources are used by certain feature areas in WPF, notably for styles, component resources, and data styling. You can use a defined resource with the resource markup extension syntax that specifies the key name of the resource. For example, use the resource as the value of a property on another element. ```xaml ` anywhere in the page, and the style you defined with of `Button` would apply to that button. If you want, you can still explicitly key the style with the same type value as for clarity in your markup, but that is optional. Implicit keys for styles don't apply on a control if is `true`. (Also note that might be set as part of native behavior for the control class, rather than explicitly on an instance of the control.) Also, to support implicit keys for derived class scenarios, the control must override (all existing controls provided as part of WPF include this override). For more information about styles, themes, and control design, see [Guidelines for Designing Stylable Controls](../../../framework/wpf/controls/guidelines-for-designing-stylable-controls.md). also has an implicit key. The implicit key for a is the property value. can also be specified as the name of the type rather than explicitly using [{x:Type...}](../../../xaml-services/xtype-markup-extension.md). For details, see [Data Templating Overview](../../../framework/wpf/data/data-templating-overview.md). ## See also - [Resources in code](xaml-resources-and-code.md) - [Merged resource dictionaries](xaml-resources-merged-dictionaries.md) - [How to define and reference a WPF resource](xaml-resources-how-to-define-and-reference.md) - [How to use system resources](xaml-resources-how-to-use-system.md) - [How to use application resources](xaml-resources-how-to-use-application.md) - [x:Type markup extension](../../../xaml-services/xtype-markup-extension.md) - - [Application resources](../../../framework/wpf/advanced/optimizing-performance-application-resources.md) - [Define and reference a resource](../../../framework/wpf/advanced/how-to-define-and-reference-a-resource.md) - [Application management overview](../../../framework/wpf/app-development/application-management-overview.md) - [StaticResource markup extension](../../../framework/wpf/advanced/staticresource-markup-extension.md) - [DynamicResource markup extension](../../../framework/wpf/advanced/dynamicresource-markup-extension.md)