Udostępnij za pośrednictwem


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.

public:
 virtual ResourceCandidate ^ TryGetValue(Platform::String ^ resource) = TryGetValue;
/// [Windows.Foundation.Metadata.Overload("TryGetValue")]
ResourceCandidate TryGetValue(winrt::hstring const& resource);
[Windows.Foundation.Metadata.Overload("TryGetValue")]
public ResourceCandidate TryGetValue(string resource);
function tryGetValue(resource)
Public Function TryGetValue (resource As String) As ResourceCandidate

Parameters

resource
String

Platform::String

winrt::hstring

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

TryGetValue(String, ResourceContext)

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

public:
 virtual ResourceCandidate ^ TryGetValue(Platform::String ^ resource, ResourceContext ^ context) = TryGetValue;
/// [Windows.Foundation.Metadata.Overload("TryGetValueWithContext")]
ResourceCandidate TryGetValue(winrt::hstring const& resource, ResourceContext const& context);
[Windows.Foundation.Metadata.Overload("TryGetValueWithContext")]
public ResourceCandidate TryGetValue(string resource, ResourceContext context);
function tryGetValue(resource, context)
Public Function TryGetValue (resource As String, context As ResourceContext) As ResourceCandidate

Parameters

resource
String

Platform::String

winrt::hstring

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