Redigera

Dela via


Application.LoadComponent Method

Definition

Loads a XAML file that is located at the specified uniform resource identifier (URI).

Overloads

LoadComponent(Uri)

Loads a XAML file that is located at the specified uniform resource identifier (URI), and converts it to an instance of the object that is specified by the root element of the XAML file.

LoadComponent(Object, Uri)

Loads a XAML file that is located at the specified uniform resource identifier (URI) and converts it to an instance of the object that is specified by the root element of the XAML file.

Remarks

The XAML file can be an application code file (configured as an Microsoft build engine (MSBuild) Page item) or an application data file (a resource file, content file, or site-of-origin file; see WPF Application Resource, Content, and Data Files).

Note

This method is not thread-safe.

LoadComponent(Uri)

Loads a XAML file that is located at the specified uniform resource identifier (URI), and converts it to an instance of the object that is specified by the root element of the XAML file.

public:
 static System::Object ^ LoadComponent(Uri ^ resourceLocator);
public static object LoadComponent (Uri resourceLocator);
static member LoadComponent : Uri -> obj
Public Shared Function LoadComponent (resourceLocator As Uri) As Object

Parameters

resourceLocator
Uri

A Uri that maps to a relative XAML file.

Returns

An instance of the root element specified by the XAML file loaded.

Exceptions

resourceLocator is null.

The resourceLocator is an absolute URI.

The file is not a XAML file.

Remarks

You must explicitly convert the return value to the same type as the root element of the XAML file.

The XAML file can be an application code file (configured as an Microsoft build engine (MSBuild) Page item) or an application data file (a resource file, content file, or site-of-origin file; see WPF Application Resource, Content, and Data Files).

Note

This method is not thread-safe.

See also

Applies to

LoadComponent(Object, Uri)

Loads a XAML file that is located at the specified uniform resource identifier (URI) and converts it to an instance of the object that is specified by the root element of the XAML file.

public:
 static void LoadComponent(System::Object ^ component, Uri ^ resourceLocator);
[System.Security.SecurityCritical]
public static void LoadComponent (object component, Uri resourceLocator);
public static void LoadComponent (object component, Uri resourceLocator);
[<System.Security.SecurityCritical>]
static member LoadComponent : obj * Uri -> unit
static member LoadComponent : obj * Uri -> unit
Public Shared Sub LoadComponent (component As Object, resourceLocator As Uri)

Parameters

component
Object

An object of the same type as the root element of the XAML file.

resourceLocator
Uri

A Uri that maps to a relative XAML file.

Attributes

Exceptions

resourceLocator is null.

The resourceLocator is an absolute URI.

component is of a type that does not match the root element of the XAML file.

Remarks

The XAML file can be an application code file (configured as an Microsoft build engine (MSBuild) Page item) or an application data file (a resource file, content file, or site-of-origin file; see WPF Application Resource, Content, and Data Files).

Note

This method is not thread-safe.

See also

Applies to