Application.LoadComponent(Object, Uri) method

This topic has not yet been rated - Rate this topic

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.

Syntax


public static void LoadComponent(
  object component, 
  Uri resourceLocator
)

Parameters

component

Type: System.Object [.NET] | Platform::Object [C++]

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

resourceLocator

Type: System.Uri [.NET] | Windows::Foundation::Uri [C++]

An object describing the URI path to the resource to load.

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.

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Namespace

Windows.UI.Xaml
Windows::UI::Xaml [C++]

Metadata

Windows.winmd

See also

Application
LoadComponent(Object, Uri, ComponentResourceLocation)

 

 

Build date: 1/31/2013

Did you find this helpful?
(1500 characters remaining)
© 2013 Microsoft. All rights reserved.