LoadComponent () Vs. XamlReader.Load ()?

In connection with an earlier question, I asked: I saw that both LoadComponent () and XamlReader.Load () are there. They are so similar that I'm not entirely sure which one I should use in which case.

So basically, what's the difference between the two?

Thanks!

+1


a source to share


2 answers


MSDN :



Speculation
I would guess that LoadComponent is calling XamlReader.Load()

. LoadComponent is more like an application layer service and is probably used by the application itself to load all xaml resources. XamlReader is a special library call for whatever you want.

Think about it as LoadComponent is an Application Service where XamlReader is a library that contains functionality.

+4


a source


Application.LoadComponent: Application will first preload resources as "Package" and register it in PreloadedPackage class when calling LoadComponent method, wpf will first check if exesits and package resource exist, then check if resouse is xaml or baml, finally load resource stream with provided BaseUri

If the resource is a baml the LoadComponent will use the Baml2006Reader, otherwise use the XamlReader to handle the resource stream.



XamlReader.Load can load xaml resources outside of assembly.

+1


a source







All Articles