FrameworkContentElement.FindResource Method
Assembly: PresentationFramework (in presentationframework.dll)
public Object FindResource ( Object resourceKey )
public function FindResource ( resourceKey : Object ) : Object
You cannot use methods in XAML.
Parameters
- resourceKey
Key identifier of the resource to be found.
Return Value
The found resource, or a null reference (Nothing in Visual Basic) if no matching resource was found (but will also raise an exception if a null reference (Nothing in Visual Basic)).![]() |
---|
If you call this method for a key that cannot be found, an exception is raised. If you do not want to handle exceptions for this case, you should instead call TryFindResource. TryFindResource returns a null reference (Nothing in Visual Basic) when no resource is found, and does not raise an exception. |
If the resource is not found on the calling element, the parent tree is searched using the logical tree, in the same way that the tree would be searched if a resource were requested by key at run-time.
Typically you would immediately cast the return value to the type of the property that you were attempting to set with the returned resource value.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.