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.
Assembly: System.Windows (in System.Windows.dll)
[SecuritySafeCriticalAttribute] public static void LoadComponent( Object component, Uri resourceLocator )
The XAML file that is loaded can be either an application definition file (App.xaml, for example) or a page file (MainPage.xaml, for example). The XAML file can be in one of the following locations:
Included in the application package.
Embedded in the application assembly.
Embedded within a library assembly at the site of origin.
The following code example demonstrates how to use this method to merge the XAML and code-behind portions of a Page class. This code is similar to the InitializeComponent method that Visual Studio generates for the same purpose.
Visual Studio generates the InitializeComponent method when a XAML file has a build action of Page. To load a XAML file using the following example code, set its build action to Resource.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.