Files
docs-desktop/dotnet-desktop-guide/framework/wpf/advanced/how-to-use-application-resources.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* Reset branch for WPF changes

* Convert BMP to PNG; fix link-out-of-scope err

* Add snippets for WPF... 6794 files!!!!

* Add missing snippets

* update file updated between migration

* Fix paths to include

* update breadcrumb and toc

* fix index links

* fix index links

* fix index links

* fix markdown
2020-09-04 09:46:28 -07: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 [!INCLUDETLA2#tla_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