System.Windows.Application.LoadComponent C# (CSharp) Method

LoadComponent() public static method

public static LoadComponent ( object component, Uri resourceLocator ) : void
component object
resourceLocator Uri
return void
		public static void LoadComponent (object component, Uri resourceLocator)
		{			
			if (component == null)
				throw new ArgumentNullException ("component");

			if (resourceLocator == null)
				throw new ArgumentNullException ("resourceLocator");

			StreamResourceInfo sr = GetResourceStream (resourceLocator);

			// Does not seem to throw.
			if (sr == null)
				return;

			using (var v = Value.FromObject (component)) {
				// XXX still needed for the app.surface reference when creating the ManagedXamlLoader
				// Application app = component as Application;
	
				string xaml = new StreamReader (sr.Stream).ReadToEnd ();
				Assembly loading_asm = component.GetType ().Assembly;
	
				ManagedXamlLoader loader = new ManagedXamlLoader (loading_asm, resourceLocator.ToString(), Deployment.Current.Surface.Native, PluginHost.Handle);
				loader.Hydrate (v, xaml);
			}
		}

Usage Example

示例#1
0
 public void InitializeComponent()
 {
     if (_contentLoaded)
     {
         return;
     }
     _contentLoaded = true;
     Application.LoadComponent(this, new Uri("/Manager;component/editpicturecontrol.xaml", UriKind.Relative));
 }
All Usage Examples Of System.Windows.Application::LoadComponent