Some of the examples I've seen are more complicated than they should be, but this is not an easy task. It took me 2 days to break down the examples that I could find before I really understood what was going on.
To do this, you need to create at least two classes. A class that implements INavigationContentLoader will do all the work. A class that implements IAsyncResult. This object will be passed to INavigationContentLoader, so use it to keep track of what you are doing.
Your INavgiationContentLoader should do the following.
Beginload
- Check if Uri belongs to the current XAP or XAP that has already been loaded.
- If not, use DeploymentCatalog to download XAP. Store DeploymentCatalog in AggregateCatalog.
- Uri, ExportFactory. IAsyncResult, .
- , .
CanLoad
, , XAP, true .
CancelLoad
IAsyncResult, , .
EndLoad
- , IAsyncResult, LoadResult .
, INavgiationContentLoader, ExportAttribute, ExportFactory .
My InavigationContentLoader
http://pastebin.com/cT1mJ4Ve
IAsyncResult
http://pastebin.com/xHWHT4pr
ExportAttribute . all, XAP.
http://pastebin.com/nTJ27mWz
IExportPageMetaData. , MEF.
http://pastebin.com/8fdwx2Kn
:
: ,
<navigation:Frame x:Name="ContentFrame"
Source="/Home"`
Grid.Column="1">
<navigation:Frame.ContentLoader>
<navUtil:DynamicContentLoader />
</navigation:Frame.ContentLoader>
</navigation:Frame>
HyperlinkButton XAP.
<HyperlinkButton Content="Page from another XAP"
NavigateUri="/NavigateUriFromExportPageAttribute"
navUtil:DynamicContentLoader.Xap="UriToOtherXap" />
HyperlinkButton XAP.
<HyperlinkButton Content="Page from this XAP"
NavigateUri="/NavigateUriFromExportPageAttribute" />
UriMapper, Path of the page.xaml. MEF ExportPageAttribute Uri .