Provides simplified access to app resources such as app UI strings.
The ResourceLoader class has these types of members:
The ResourceLoader class has these constructors.
|ResourceLoader()||Constructs a new ResourceLoader object for the Resources subtree of the currently running app's main ResourceMap.|
|ResourceLoader(String)||Constructs a new ResourceLoader object for the specified ResourceMap.|
The ResourceLoader class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.
|GetForCurrentView()||Gets a ResourceLoader object for the Resources subtree of the currently running app's main ResourceMap.|
|GetForCurrentView(String)||Gets a ResourceLoader object for the specified ResourceMap.|
|GetForViewIndependentUse()||Gets a ResourceLoader object for the Resources subtree of the currently running app's main ResourceMap. This ResourceLoader uses a default context that's not associated with any view.|
|GetForViewIndependentUse(String)||Gets a ResourceLoader object for the specified ResourceMap. This ResourceLoader uses a default context that's not associated with any view.|
|GetString||Returns the most appropriate string value of a resource, specified by resource identifier, for the default ResourceContext of the view in which the ResourceLoader was obtained using ResourceLoader.GetForCurrentView.|
|GetStringForReference||Returns the most appropriate string value of a resource, specified as a Uri for a resource identifier, for the default ResourceContext of the currently running app.|
|GetStringForUri||Returns the most appropriate string value of a resource, specified by a Uniform Resource Identifier (URI) resource identifier, for the default ResourceContext of the currently running app.|
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 8: Windows Store apps 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 Windows 8.1: Multiple monitors can display multiple Windows Store apps 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.
Use the ResourceLoader.GetString | getString method to get the string resource identified by "Farewell".
var loader = new Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView(); var text = loader.GetString("Farewell");
Minimum supported client
|Windows 8 [Windows Store apps only]|
Minimum supported server
|Windows Server 2012 [Windows Store apps only]|
End of client support
End of server support
|Windows Server 2012 R2|
- Creating and retrieving resources in Windows Store apps
- Guidelines for window sizes and scaling to screens
- Guidelines for scaling to pixel density
- Application resources and localization sample
Build date: 11/16/2013