Application.LoadComponent Method

Definition

Overloads

LoadComponent(Object, Uri)

Loads a XAML file that is located at the specified relative location, and converts it to an instance of the object that is specified by the root element of the XAML file.

LoadComponent(Object, Uri, ComponentResourceLocation)

Loads a XAML file that is located at the specified relative location, 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 relative location, and converts it to an instance of the object that is specified by the root element of the XAML file.

C#
[Windows.Foundation.Metadata.Overload("LoadComponent")]
public static void LoadComponent(object component, System.Uri resourceLocator);

Parameters

component
Object

An object of the same type as the root element of the XAML content to be loaded.

resourceLocator
Uri

An object describing the Uniform Resource Identifier (URI) path to the resource to load.

Attributes

Remarks

LoadComponent exists mainly for infrastructure. You can see LoadComponent as part of the generated InitializeComponent logic that integrates the partial classes of a XAML page and its code-behind.

LoadComponent sometimes is cited in a call stack for an exception that is ultimately because your app is trying to parse bad XAML. In this case there's nothing that app code can do to change how LoadComponent is used, and the way to fix the problem is to check your XAML source in an XML editor and fix it. What might be helpful from the stack trace message is confirming which XAML file is not loading. In scenarios where you have merged resources or other multiple XAML sources being combined, it's not always the obvious page-level XAML that is failing to parse.

Most app scenarios that involve loading XAML content and producing an object tree should use XamlReader.Load instead.

See also

Applies to

Windows App SDK 1.6 i druge verzije
Proizvod Verzije
Windows App SDK 0.8, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6

LoadComponent(Object, Uri, ComponentResourceLocation)

Loads a XAML file that is located at the specified relative location, and converts it to an instance of the object that is specified by the root element of the XAML file.

C#
[Windows.Foundation.Metadata.Overload("LoadComponentWithResourceLocation")]
public static void LoadComponent(object component, System.Uri resourceLocator, ComponentResourceLocation componentResourceLocation);

Parameters

component
Object

An object of the same type as the root element of the XAML content to be loaded.

resourceLocator
Uri

An object describing the Uniform Resource Identifier (URI) path to the resource to load.

componentResourceLocation
ComponentResourceLocation

A value of the enumeration.

Attributes

See also

Applies to

Windows App SDK 1.6 i druge verzije
Proizvod Verzije
Windows App SDK 0.8, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6