Assembly: PresentationFramework (in PresentationFramework.dll)
will first look in application-scope resources for the specified resource. Application-scope resources are managed by Application, and are exposed from the Resources property. If the specified resource is not found in the set of application-scope resources, then next searches the system resources. System resources are shell resources defined by the user, and include colors, fonts, and shell configurations. These are exposed from the SystemColors, SystemFonts, and SystemParameters types, respectively, as static properties. To use to acquire them, these types also expose resource key properties that are designed to be passed to ; for example, IconWidthKey.
Because returns an object, you must cast the returned value to the appropriate type if the resource is found.
If you call this method for a key that cannot be found, an exception is thrown. If you do not want to handle exceptions that result from calling , call TryFindResource instead; TryFindResource returns a null reference when a requested resource cannot be found, and does not throw an exception.
This method is thread safe and can be called from any thread.
The following example shows how to use to find a resource, and to handle ResourceReferenceKeyNotFoundException if the resource is not found.
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.