FrameworkElementExtensions.TryFindResource Method

Definition

Overloads

TryFindResource(FrameworkElement, Object)

Provides a WPF compatible version of TryFindResource to provide a static resource lookup. If the key is not found in the current element's resources, the logical tree is then searched element-by-element to look for the resource in each element's resources. If none of the elements contain the resource, the Application's resources are then searched.

See: https://docs.microsoft.com/dotnet/api/system.windows.frameworkelement.tryfindresource.

And also: https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/xaml-resources-define#static-resource-lookup-behavior.

TryFindResource(FrameworkElement, Object, Object)

Provides a WPF compatible version of TryFindResource to provide a static resource lookup. If the key is not found in the current element's resources, the logical tree is then searched element-by-element to look for the resource in each element's resources. If none of the elements contain the resource, the Application's resources are then searched.

See: https://docs.microsoft.com/dotnet/api/system.windows.frameworkelement.tryfindresource.

And also: https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/xaml-resources-define#static-resource-lookup-behavior.

TryFindResource(FrameworkElement, Object)

Provides a WPF compatible version of TryFindResource to provide a static resource lookup. If the key is not found in the current element's resources, the logical tree is then searched element-by-element to look for the resource in each element's resources. If none of the elements contain the resource, the Application's resources are then searched.

See: https://docs.microsoft.com/dotnet/api/system.windows.frameworkelement.tryfindresource.

And also: https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/xaml-resources-define#static-resource-lookup-behavior.

public static object? TryFindResource (this Windows.UI.Xaml.FrameworkElement element, object resourceKey);
static member TryFindResource : Windows.UI.Xaml.FrameworkElement * obj -> obj
<Extension()>
Public Function TryFindResource (element As FrameworkElement, resourceKey As Object) As Object

Parameters

element
Windows.UI.Xaml.FrameworkElement

The Windows.UI.Xaml.FrameworkElement to start searching for the target resource.

resourceKey
Object

The resource key to search for.

Returns

The requested resource, or null if it wasn't found.

Applies to

TryFindResource(FrameworkElement, Object, Object)

Provides a WPF compatible version of TryFindResource to provide a static resource lookup. If the key is not found in the current element's resources, the logical tree is then searched element-by-element to look for the resource in each element's resources. If none of the elements contain the resource, the Application's resources are then searched.

See: https://docs.microsoft.com/dotnet/api/system.windows.frameworkelement.tryfindresource.

And also: https://docs.microsoft.com/dotnet/desktop-wpf/fundamentals/xaml-resources-define#static-resource-lookup-behavior.

public static bool TryFindResource (this Windows.UI.Xaml.FrameworkElement element, object resourceKey, out object? value);
static member TryFindResource : Windows.UI.Xaml.FrameworkElement * obj * obj -> bool
<Extension()>
Public Function TryFindResource (element As FrameworkElement, resourceKey As Object, ByRef value As Object) As Boolean

Parameters

element
Windows.UI.Xaml.FrameworkElement

The Windows.UI.Xaml.FrameworkElement to start searching for the target resource.

resourceKey
Object

The resource key to search for.

value
Object

The resulting value, if present.

Returns

Whether or not a value with the specified key has been found.

Applies to