Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-application-resources.md
T
Andy (Steve) De George be103da07e Replace various WPF include files with content (#1335)
* net-current-v30plus-md.md

* net-current-v40plus-md.md

* tla2sharptla-ui-md.md

* tla2sharptla-uiautomation-md.md

* tla2sharptla-winclient-md.md

* tla2sharptla-xaml-md.md

* tlasharptla-ui-md.md

* tlasharptla-uiautomation-md.md

* tlasharptla-winclient-md.md

* tlasharptla-xaml-md.md

* fix warnings
2022-03-16 12:14:11 -04:00

2.1 KiB

title, ms.date, helpviewer_keywords, ms.assetid
title ms.date helpviewer_keywords ms.assetid
How to: Use Application Resources 03/30/2017
application resources [WPF]
resources [WPF], application resources
507ea937-5191-406b-8797-0a3d9f94156d

How to: Use Application Resources

This example shows how to use application resources.

Example

The following example shows an application definition file. The application definition file defines a resource section (a value for the xref:System.Windows.Application.Resources%2A property). Resources defined at the application level can be accessed by all other pages that are part of the application. In this case, the resource is a declared style. Because a complete style that includes a control template can be lengthy, this example omits the control template that is defined within the xref:System.Windows.Controls.ContentControl.ContentTemplate%2A property setter of the style.

[!code-xamlResourcesApplication#PreTemplateResource]
[!code-xamlResourcesApplication#PostTemplateResource]

The following example shows a XAML page that references the application-level resource that the previous example defined. The resource is referenced by using a StaticResource Markup Extension that specifies the unique resource key for the requested resource. No resource with key of "GelButton" is found in the current page, so the resource lookup scope for the requested resource continues beyond the current page and into the defined application-level resources.

[!code-xamlResourcesApplication#ConsumingPage]

See also