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!
a source to share
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.
a source to share
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.
a source to share