Share via


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.

public:
 static void LoadComponent(Platform::Object ^ component, Uri ^ resourceLocator);
/// [Windows.Foundation.Metadata.Overload("LoadComponent")]
 static void LoadComponent(IInspectable const& component, Uri const& resourceLocator);
[Windows.Foundation.Metadata.Overload("LoadComponent")]
public static void LoadComponent(object component, System.Uri resourceLocator);
function loadComponent(component, resourceLocator)
Public Shared Sub LoadComponent (component As Object, resourceLocator As Uri)

Parameters

component
Object

Platform::Object

IInspectable

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

resourceLocator
Uri 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

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.

public:
 static void LoadComponent(Platform::Object ^ component, Uri ^ resourceLocator, ComponentResourceLocation componentResourceLocation);
/// [Windows.Foundation.Metadata.Overload("LoadComponentWithResourceLocation")]
 static void LoadComponent(IInspectable const& component, Uri const& resourceLocator, ComponentResourceLocation const& componentResourceLocation);
[Windows.Foundation.Metadata.Overload("LoadComponentWithResourceLocation")]
public static void LoadComponent(object component, System.Uri resourceLocator, ComponentResourceLocation componentResourceLocation);
function loadComponent(component, resourceLocator, componentResourceLocation)
Public Shared Sub LoadComponent (component As Object, resourceLocator As Uri, componentResourceLocation As ComponentResourceLocation)

Parameters

component
Object

Platform::Object

IInspectable

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

resourceLocator
Uri 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