FrameworkElementExtensions.FindResource(FrameworkElement, Object) Method

Definition

Provides a WPF compatible version of FindResource 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.findresource.

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

public static object FindResource (this Windows.UI.Xaml.FrameworkElement element, object resourceKey);
static member FindResource : Windows.UI.Xaml.FrameworkElement * obj -> obj
<Extension()>
Public Function FindResource (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.

Exceptions

Thrown when no resource is found with the specified key.

Applies to