Skip to content

Latest commit

 

History

History
47 lines (28 loc) · 4.56 KB

resourceloader.md

File metadata and controls

47 lines (28 loc) · 4.56 KB
-api-id -api-type
T:Windows.ApplicationModel.Resources.ResourceLoader
winrt class

Windows.ApplicationModel.Resources.ResourceLoader

-description

Provides simplified access to app resources such as app UI strings.

-remarks

A ResourceLoader object encapsulates a particular ResourceMap and a ResourceContext, combined in a simple API.

A specific resource map can be specified when the ResourceLoader is obtained; if no resource map is specified, the ResourceLoader will provide access to the "Resources" subtree of the app's main resource map.

In general, resources can be sensitive to scale or other display characteristics. For that reason, resource contexts are generally associated with a specific view. Since a ResourceLoader encapsulates a resource context, this also applies to a ResourceLoader. A ResourceLoader obtained using GetForCurrentView has a resource context associated with a view in which it was obtained. A view-independent ResourceLoader can also be obtained using GetForViewIndependentUse.

  • In : Windows Store app could show their UI on only a single monitor at a time. Frameworks and apps therefore used only a single scale factor at a time, which would change if the app was displayed on a different monitor.
  • Beginning in : Multiple monitors can display multiple Windows Store app at a time, and one app can appear on multiple monitors simultaneously. Frameworks and apps therefore have to deal with multiple scale factors at a time. For Windows 8.1 apps:
  • Obtain the scale factor for the current view by using the DisplayInformation class instead of the deprecated DisplayProperties class.
  • Apps that set explicit width and height of elements should still work fine, other than possibly displaying blurry images.
  • Obtain resources that are not associated with any view by getting a ResourceLoader via GetForViewIndependentUse.

See Guidelines for window sizes and scaling to screens and UX guidelines for layout and scaling.

-examples

Use the ResourceLoader.GetString | getString method to get the string resource identified by "Farewell".

[!code-jsResourceLoaderJS]

[!code-csharpResourceLoaderCS]

[!code-vbResourceLoaderVB]

[!code-cppResourceLoaderCPP]

-see-also

GetForCurrentView, GetForCurrentView(String), GetForViewIndependentUse, GetForViewIndependentUse(String), ResourceMap, ResourceContext, Creating and retrieving resources in , Guidelines for window sizes and scaling to screens, UX guidelines for layout and scaling, Application resources and localization sample, Application resources and localization sample (Windows 10)