ResourceLoader ResourceLoader ResourceLoader ResourceLoader ResourceLoader Class

Definition

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

public : sealed class ResourceLoader : IResourceLoader, IResourceLoader2
struct winrt::Windows::ApplicationModel::Resources::ResourceLoader : IResourceLoader, IResourceLoader2
public sealed class ResourceLoader : IResourceLoader, IResourceLoader2
Public NotInheritable Class ResourceLoader Implements IResourceLoader, IResourceLoader2
var resourceLoader = new resourceLoader();
Attributes

Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

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

var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.GetForCurrentView();
var text = resourceLoader.GetString("Farewell");
auto resourceLoader{ Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView() };
winrt::hstring text{ resourceLoader.GetString(L"Farewell") };
auto resourceLoader = Windows::ApplicationModel::Resources::ResourceLoader::GetForCurrentView();
String^ text = resourceLoader->GetString("Farewell");
var resourceLoader = Windows.ApplicationModel.Resources.ResourceLoader.getForCurrentView();
var text = resourceLoader.getString('Farewell');

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.

  • 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.

Also see Screen sizes and breakpoints.

Constructors

ResourceLoader() ResourceLoader() ResourceLoader() ResourceLoader() ResourceLoader()

Note

ResourceLoader() may be altered or unavailable for releases after Windows 8.1. Instead, use GetForCurrentView().

Constructs a new ResourceLoader object for the "Resources" subtree of the currently running app's main ResourceMap.

ResourceLoader(String) ResourceLoader(String) ResourceLoader(String) ResourceLoader(String) ResourceLoader(String)

Note

ResourceLoader(String) may be altered or unavailable for releases after Windows 8.1. Instead, use GetForCurrentView(String).

Constructs a new ResourceLoader object for the specified ResourceMap.

Methods

GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView()

Gets a ResourceLoader object for the Resources subtree of the currently running app's main ResourceMap. This ResourceLoader uses a default context associated with the current view.

GetForCurrentView(String) GetForCurrentView(String) GetForCurrentView(String) GetForCurrentView(String) GetForCurrentView(String)

Gets a ResourceLoader object for the specified ResourceMap. This ResourceLoader uses a default context associated with the current view.

GetForViewIndependentUse() GetForViewIndependentUse() GetForViewIndependentUse() GetForViewIndependentUse() 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) GetForViewIndependentUse(String) GetForViewIndependentUse(String) GetForViewIndependentUse(String) GetForViewIndependentUse(String)

Gets a ResourceLoader object for the specified ResourceMap. This ResourceLoader uses a default context that's not associated with any view.

GetString(String) GetString(String) GetString(String) GetString(String) GetString(String)

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(Uri) GetStringForReference(Uri) GetStringForReference(Uri) GetStringForReference(Uri) GetStringForReference(Uri)

Note

GetStringForReference may be altered or unavailable for releases after Windows 8.1. Instead, use GetStringForUri.

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(Uri) GetStringForUri(Uri) GetStringForUri(Uri) GetStringForUri(Uri) GetStringForUri(Uri)

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.

See also