ResourceMap.TryGetValue Method

Definition

Overloads

TryGetValue(String)

Tries to find the most appropriate candidate for a resource that is specified by a resource identifier within the default context.

TryGetValue(String, ResourceContext)

Tries to find the most appropriate candidate for a resource that is specified by a resource identifier for the supplied context.

TryGetValue(String)

Tries to find the most appropriate candidate for a resource that is specified by a resource identifier within the default context.

C#
[Windows.Foundation.Metadata.Overload("TryGetValue")]
public ResourceCandidate TryGetValue(string resource);

Parameters

resource
String

A resource identifier specified as a name or reference. For details, see the remarks for ResourceMap class.

Returns

A ResourceCandidate that describes the most appropriate candidate. If the specified resource identifier is not found, this method returns null.

Attributes

Applies to

Windows App SDK 1.6 and other versions
Product Versions
Windows App SDK 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6

TryGetValue(String, ResourceContext)

Tries to find the most appropriate candidate for a resource that is specified by a resource identifier for the supplied context.

C#
[Windows.Foundation.Metadata.Overload("TryGetValueWithContext")]
public ResourceCandidate TryGetValue(string resource, ResourceContext context);

Parameters

resource
String

A resource specified as a name or reference. For details, see the remarks for ResourceMap class.

context
ResourceContext

The context for which to select the most appropriate candidate.

Returns

A ResourceCandidate that describes the most appropriate candidate. If the specified resource identifier is not found, this method returns null.

Attributes

Remarks

Some resources are loaded according to the scale of the view where they will be displayed, and different views within an app might be displayed on different devices with different scales. Scale is a per-view characteristic.

Since the TryGetValue method selects the best candidate for the specified resource in relation to a runtime context, and since the scale qualifier of a ResourceContext depends on the associated view, TryGetValue should always be called with a ResourceContext object obtained from the view in which the resource will be used.

Applies to

Windows App SDK 1.6 and other versions
Product Versions
Windows App SDK 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6