<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;CkENRHoyfyp7ImA9WhBbE0Q.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825</id><updated>2013-05-12T21:31:35.497+01:00</updated><category term="Ribbon" /><category term="MEF" /><category term="Windows Phone 7" /><category term="DataLists" /><category term="DropDownButton" /><category term="MVVM" /><category term="Windows 8" /><category term="Metro" /><category term="Cocoon" /><category term="Chrysalis" /><category term="Navigation" /><category term="dropshadows" /><category term="WPF" /><category term="Okra" /><title>Andy On WPF, Windows 8 and Beyond</title><subtitle type="html" /><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://andyonwpf.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>41</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/AndyOnWpf" /><feedburner:info uri="andyonwpf" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;CkENRHs6eSp7ImA9WhBbE0Q.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-4447007227662121521</id><published>2013-05-12T21:31:00.000+01:00</published><updated>2013-05-12T21:31:35.511+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-12T21:31:35.511+01:00</app:edited><title>Windows Store MVVM Templates for Visual Studio</title><content type="html">&lt;p&gt;If you have ever tried to create a Windows Store application using the MVVM pattern then you will probably have found that the Visual Studio project and item templates are a bit cumbersome. I often find myself adding a new page to my projects using one of the default templates, only to need to rewrite it to follow the MVVM pattern before I can even start adding application specific logic. What if there was a way to take advantage of the selection of project and page templates provided by Visual Studio, but have them produce fully MVVM compliant code?&lt;/p&gt;
&lt;p&gt;Well today I’d like to announce the release of a free extension for Visual Studio 2012 (including the Express editions for Windows 8) that provides just that. It is based upon the open source &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framework&lt;/a&gt;, and provides almost all of the Visual Studio Windows Store templates in an MVVM friendly manner.&lt;/p&gt;
&lt;h2&gt;
Installing the Extension&lt;/h2&gt;
&lt;p&gt;The “Windows Store MVVM Templates for the Okra App Framework” extension is available for download from the &lt;a href="http://visualstudiogallery.msdn.microsoft.com/4cac9393-772c-49ab-af20-9dbf9972adf7?SRC=Home"&gt;Visual Studio Gallery&lt;/a&gt;, or available directly in the Visual Studio Extensions and Updates manager (the recommended method). Instructions for installing via Visual Studio are available at the &lt;a href="http://okra.codeplex.com/wikipage?title=Downloading%20the%20Okra%20App%20Framework"&gt;Downloading the Okra App Framework&lt;/a&gt; page in the Okra App Framework documentation.&lt;/p&gt;
&lt;h2&gt;
What Templates are Provided?&lt;/h2&gt;
&lt;p&gt;There are two types of template included, project templates and item templates. The project templates are designed to get you started with a new application and provide exactly the same behaviour as the default Visual Studio templates (but written following the MVVM pattern).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Okra Basic App - A single-page Okra App Framework project with no predefined controls or layout.
&lt;li&gt;Okra Grid App - A three-page Okra App Framework project that navigates among grouped items arranged in a grid. Dedicated pages display group and item details.
&lt;li&gt;Okra Split App - A two-page Okra App Framework project that navigates among grouped items. The first page allows group selection while the second displays an item list alongside details for the selected item.&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-5AeicS3f62Y/UY_54fF9_QI/AAAAAAAAAGU/Ay6fCmObS8c/s1600/New+Project+Dialog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="275" src="http://1.bp.blogspot.com/-5AeicS3f62Y/UY_54fF9_QI/AAAAAAAAAGU/Ay6fCmObS8c/s400/New+Project+Dialog.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;Also included are a number of item templates that allow you to add new pages to any existing Okra App Framework based application, whether created using the project templates or not.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Basic Page (MVVM)
&lt;li&gt;Split Page (MVVM)
&lt;li&gt;Items Page (MVVM)
&lt;li&gt;Item Detail Page (MVVM)
&lt;li&gt;Grouped Items Page (MVVM)
&lt;li&gt;Group Detail Page (MVVM)
&lt;li&gt;Search Contract (MVVM)
&lt;li&gt;Share Target Contract (MVVM)
&lt;li&gt;Settings Pane (MVVM) &lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-SbPH84Y9MDY/UY_6iLU95mI/AAAAAAAAAGc/ET4rOtlRS1Y/s1600/New+Item+Dialog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="275" src="http://2.bp.blogspot.com/-SbPH84Y9MDY/UY_6iLU95mI/AAAAAAAAAGc/ET4rOtlRS1Y/s400/New+Item+Dialog.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-SbPH84Y9MDY/UY_6iLU95mI/AAAAAAAAAGc/ET4rOtlRS1Y/s1600/New+Item+Dialog.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;/a&gt;&amp;nbsp;&lt;/div&gt;
&lt;h2&gt;
What do the MVVM Pages Look Like?&lt;/h2&gt;
&lt;p&gt;All the page templates (and each of the pages in the project templates) include the following files,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A XAML file containing the UI design, as well as an associated code-behind file. Since we are following the MVVM pattern this code-behind file contains very little logic.&lt;/li&gt;
&lt;li&gt;A view-model that contains the properties and logic for the page.&lt;/li&gt;
&lt;li&gt;In addition a file for design-time data is provided. This allows you to easily layout complex user interfaces in the designer with a visual representation of how the resulting page will look.&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-t6DiIp7KjUQ/UY_6h27OweI/AAAAAAAAAGg/jZ68apyJSis/s1600/Project+Structure+Small.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://2.bp.blogspot.com/-t6DiIp7KjUQ/UY_6h27OweI/AAAAAAAAAGg/jZ68apyJSis/s1600/Project+Structure+Small.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;h2&gt;
Summary&lt;/h2&gt;
&lt;p&gt;As I have discussed the new “Windows Store MVVM Templates for the Okra App Framework” make it quick and easy to implement pages following the MVVM pattern for use in Windows Store applications. The behaviour of all the templates has been designed to be identical to the default Visual Studio templates, with the added benefit of clean separation of code, unit testability and design-time data.&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/e35NbtkHwXE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/4447007227662121521/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=4447007227662121521" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4447007227662121521?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4447007227662121521?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/e35NbtkHwXE/windows-store-mvvm-templates-for-visual.html" title="Windows Store MVVM Templates for Visual Studio" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-5AeicS3f62Y/UY_54fF9_QI/AAAAAAAAAGU/Ay6fCmObS8c/s72-c/New+Project+Dialog.png" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2013/05/windows-store-mvvm-templates-for-visual.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMBRXc-fCp7ImA9WhBXEUk.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-4692764859143815622</id><published>2013-03-24T16:44:00.000Z</published><updated>2013-03-24T16:44:14.954Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-24T16:44:14.954Z</app:edited><title>Improvements in Version 0.9.6 of the Okra App Framework</title><content type="html">&lt;p&gt;&lt;em&gt;To start off I would like to announce that I have just pushed a minor fix for the Okra App Framework NuGet packages with the version number v0.9.6.1. This fixes an issue with the NuGet packaging and contains the same code base as the recent v0.9.6 release. If you have previously updated to v0.9.6 via NuGet I would recommend you update to the new packages. Anyone who has downloaded the source code releases of v0.9.6 do not need to make any changes.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;Following that brief announcement I would like to use the rest of this post to discuss a couple of changes that were made with the &lt;a href="http://andyonwpf.blogspot.com/2013/03/okra-app-framework-v096-released.html"&gt;recent v0.9.6 release of the Okra App Framework&lt;/a&gt; to support more advanced activation and navigation scenarios. The good news is that these changes should not affect any existing code, however you may wish to implement these changes to take full advantage of future features within Okra.&lt;/p&gt; &lt;h2&gt;Activation of Applications via the OkraApplication class&lt;/h2&gt; &lt;p&gt;In previous releases of the Okra App Framework the recommended way of initializing your application was to create an AppBootstrapper class that derived from OkraBootstrapper. This would then be initialized from your App.xaml.cs file’s constructor,&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; App : Application&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; App()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.InitializeComponent();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;        &lt;span style="color: #008000"&gt;// *** NB: THIS CODE IS NOT RECOMMENDED! ***&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;        AppBootstrapper bootstrapper = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AppBootstrapper();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        bootstrapper.Initialize();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;Whilst this will continue to work for existing applications based on the Okra App Framework, this approach does not support certain types of activation, in particular the recently introduced share target support.&lt;/p&gt;&lt;p&gt;Instead the recent release has introduced an OkraApplication class that should be used to derive your App class from. The AppBootstrapper is still required and needs no further changes, however the OkraApplication class will ensure that all activation events are recognised.&lt;/p&gt;&lt;p&gt;The changes that you should make are:&lt;/p&gt;&lt;ul&gt;&lt;li&gt;Change your App.xaml.cs class to read,&lt;/li&gt;&lt;/ul&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; App : OkraApplication&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; App()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        : &lt;span style="color: #0000ff"&gt;base&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;new&lt;/span&gt; AppBootstrapper())&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.InitializeComponent();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;ul&gt;&lt;li&gt;Change the type of your App.xaml definition to be derived from OkraApplication (NB: Only the changes are shown in the code snippet below),&lt;/li&gt;&lt;/ul&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;okra:OkraApplication&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #ff0000"&gt;xmlns:okra&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="using:Okra"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;okra:OkraApplication&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;Introduction of INavigationContext&lt;/h2&gt;&lt;p&gt;The second feature I will discuss is the introduction of the INavigationContext interface. This is designed to allow more consistent navigation code, better code reuse and better support for more advanced navigation scenarios (such as those discussed &lt;a href="http://okra.codeplex.com/discussions/406171"&gt;here&lt;/a&gt; and &lt;a href="http://konaguidance.codeplex.com/discussions/433199"&gt;here&lt;/a&gt;).&lt;/p&gt;&lt;p&gt;In previous releases of the Okra App Framework you would support navigation from you view-model by importing an INavigationManager. For example,&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MyViewModel : NotifyPropertyChangedBase&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #008000"&gt;// *** NB: NO LONGER RECOMMENDED ***&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    [Import]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    INavigationManager NavigationManager { get; set; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;If you were writing a settings pane then INavigationManager would be replaced with ISettingsPaneManager, and in other cases (such as file pickers or in multiple navigation applications) you may have a number of simultaneous navigation stacks of the same type to choose from.&lt;/p&gt;&lt;p&gt;With the v0.9.6 release of the Okra App Framework this has all been consolidated into a single INavigationContext interface. This can be imported via your view-models constructor and will return the correct navigation manager for the current page’s context,&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MyViewModel : NotifyPropertyChangedBase&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    INavigationBase NavigationManager { get; &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; set; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    [ImportingConstructor]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MyViewModel(INavigationContext context)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.NavigationManager = context.GetCurrent();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;     ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;The advantage of this approach is that you can use the same code in any of the cases mentioned above, and even reuse the same view-model definition between different contexts.&lt;/p&gt;&lt;h2&gt;Summary&lt;/h2&gt;&lt;p&gt;In this post I have discussed a couple of improvements in the latest release of the Okra App Framework. Whilst existing code should continue to work using the old mechanisms, I would recommend that you adapt your code to take advantage of the benefits described above.&lt;/p&gt;&lt;p&gt;Version 0.9.6 of the Okra App Framework is available from the Okra &lt;a href="http://okra.codeplex.com/"&gt;CodePlex&lt;/a&gt; site and via &lt;a href="http://www.nuget.org/Packages/Okra.MEF"&gt;NuGet&lt;/a&gt; (v0.9.6.1). &lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/LnpT47WBjCI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/4692764859143815622/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=4692764859143815622" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4692764859143815622?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4692764859143815622?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/LnpT47WBjCI/improvements-in-version-096-of-okra-app.html" title="Improvements in Version 0.9.6 of the Okra App Framework" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2013/03/improvements-in-version-096-of-okra-app.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUDR3k6fip7ImA9WhBQGU0.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-8723881419237373819</id><published>2013-03-21T22:16:00.001Z</published><updated>2013-03-21T22:17:56.716Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-21T22:17:56.716Z</app:edited><title>Okra App Framework v0.9.6 Released</title><content type="html">&lt;p&gt;The latest update to the Okra App Framework has just been released and is available from the Okra &lt;a href="http://okra.codeplex.com/"&gt;CodePlex&lt;/a&gt; site and via &lt;a href="http://www.nuget.org/Packages/Okra.MEF"&gt;NuGet&lt;/a&gt;. &lt;h2&gt;New Features in This Release&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Support for the share charm (more information on these in a future post),&lt;/li&gt; &lt;ul&gt; &lt;li&gt;View-model centric share source support – by implementing ISharable on view-models they can automatically provide context specific sharing of data with other applications.&lt;/li&gt; &lt;li&gt;MVVM based share target support – implement a share target to accept data from other applications via a specified view/view-model.&lt;/li&gt; &lt;li&gt;Helper methods for task based asynchronous data sharing.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;New OkraApplication base class that will allow the framework to handle more advanced activation events in the future (more on this in a future post).&lt;/li&gt; &lt;li&gt;Introduction of an INavigationContext that can be imported into views and view-models (more on this in a future post).&lt;/li&gt; &lt;li&gt;The INavigationBase interface now has an additional CanNavigateTo(…) method that allows consumers to determine if a named page is available without performing the navigation.&lt;/li&gt; &lt;li&gt;Refactoring of state persistence into the NavigationBase abstract class to allow reuse of this logic in custom navigation scenarios.&lt;/li&gt; &lt;li&gt;Additional events are raised,&lt;/li&gt; &lt;ul&gt; &lt;li&gt;upon navigation between pages (on INavigationBase)&lt;/li&gt; &lt;li&gt;upon flyout opening/closing (on ISettingsPaneManager)&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;All exceptions on application start-up should now be injected back into the application and not lost.&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Breaking Changes&lt;/h2&gt; &lt;p&gt;There are a small number of breaking changes in this release of the framework, however most of these are unlikely to apply to users of the framework (they are mostly under-the-hood interface changes that would only be applicable in advanced scenarios).&lt;/p&gt; &lt;p&gt;The only important change is,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;The default OkraBootstrapper base class no longer implements the SearchManager property. If you are using the Okra search functionality then you should simply add the following code to your application bootstrapper.&lt;/li&gt;&lt;/ul&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[Import]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ISearchManager SearchManager { get; set; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;For reference the other breaking changes are,&lt;/p&gt;&lt;ul&gt;&lt;li&gt;The SearchManager implementation now includes a default search page name (specified in the SpecialPageNames class). Since search is now opt-in this should not cause problems for existing code.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Removal of the obsolete SetupNavigationManager() method from OkraBootstrapper – this code can simply be placed in the SetupServices() method instead.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;This IViewFactory now accepts an INavigationContext when creating pages. This should be injected during the composition process (handled automatically by the default MEF implementation).&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Additional methods/properties to the INavigationBase, IViewFactory and ISettingsPaneManager interfaces. These will need to be added to any custom implementations.&lt;/li&gt;&lt;/ul&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/r-CLGDxxGf0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/8723881419237373819/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=8723881419237373819" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/8723881419237373819?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/8723881419237373819?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/r-CLGDxxGf0/okra-app-framework-v096-released.html" title="Okra App Framework v0.9.6 Released" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2013/03/okra-app-framework-v096-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4ARnc6cSp7ImA9WhBTEEw.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-4630369088731444699</id><published>2013-02-04T21:52:00.001Z</published><updated>2013-02-04T21:55:47.919Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-04T21:55:47.919Z</app:edited><title>Creating Authentic Looking Settings Panes with SettingsChrome</title><content type="html">&lt;p&gt;In my &lt;a href="http://andyonwpf.blogspot.com/2012/12/settings-panes-and-okra-app-framework.html"&gt;last post&lt;/a&gt; I described how the &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framework&lt;/a&gt; allows you easily add multi-page settings panes to your Windows Store applications using the MVVM pattern.&lt;/p&gt; &lt;p&gt;However, the built in Windows 8 applications have a very distinctive style of settings pane and many Windows Store applications will want to recreate this style. To aid with this the Okra App Framework provides a SettingsChrome control to recreate the standard UI chrome.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-cgXw50se7nQ/URAtepRotcI/AAAAAAAAAFA/jTVI84pAXZI/s1600-h/SettingsPaneUI%25255B16%25255D.png"&gt;&lt;img title="SettingsPaneUI" style="border-top: 0px; border-right: 0px; background-image: none; border-bottom: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; border-left: 0px; display: block; padding-right: 0px; margin-right: auto" border="0" alt="SettingsPaneUI" src="http://lh4.ggpht.com/-aKsvonlOujQ/URAtglYltmI/AAAAAAAAAFI/2BiUBktDk-c/SettingsPaneUI_thumb%25255B14%25255D.png?imgmax=800" width="350" height="198"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Using the SettingsChrome control&lt;/h2&gt; &lt;p&gt;If you remember from previously, you define the UI for an Okra App Framework settings pane using a standard UserControl with the PageExportAttribute applied to it.&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[PageExport(&lt;span style="color: #006080"&gt;"MySettings"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MySettingsPage : UserControl&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;In the XAML we can add the Okra SettingsChrome control as the first child element (this can be done either manually in the XAML or added in the designer). SettingsChrome is a content control, and anything that you add inside it will be displayed within the content region of the settings pane. Also you may wish to set the width of the UserControl to define the size of the resulting settings pane.&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #ff0000"&gt;xmlns:ui&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="using:Okra.UI"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="346"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ui:SettingsChrome&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="Sample"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;        &lt;span style="color: #ff0000"&gt;Logo&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="ms-appx:///Assets/SmallLogo.png"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        &lt;span style="color: #ff0000"&gt;BackButtonCommand&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{Binding ...}"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;        &lt;span style="color: #ff0000"&gt;HeaderBackgroundBrush&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{StaticResource ...}"&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        &lt;span style="color: #ff0000"&gt;HeaderForegroundBrush&lt;/span&gt;&lt;span style="color: #0000ff"&gt;="{StaticResource ...}"&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;        &lt;span style="color: #008000"&gt;&amp;lt;!-- Insert settings pane content here --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ui:SettingsChrome&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;UserControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;There are a number of properties that you can set on SettingsChrome,&lt;/p&gt;&lt;ul&gt;&lt;li&gt;“Title” – This property allows you to set the text that is displayed at the top of the settings pane&lt;/li&gt;&lt;br /&gt;&lt;li&gt;“Logo” – This should point to an image resource to use as the application logo in the top-right corner of the settings pane&lt;/li&gt;&lt;br /&gt;&lt;li&gt;“BackButtonCommand” – This can be bound to a relevant command on the view-model and will be called whenever the user clicks on the settings pane back button&lt;/li&gt;&lt;br /&gt;&lt;li&gt;“HeaderBackgroundBrush” – This allows you to set the background colour for the settings pane header. Generally this will be a static resource set to the same colour used for application tile background&lt;/li&gt;&lt;br /&gt;&lt;li&gt;“HeaderForegroundBrush” – This allows you to set the foreground colour for the settings pane header&lt;/li&gt;&lt;/ul&gt;&lt;h2&gt;Summary&lt;/h2&gt;&lt;p&gt;To summarise, the Okra App Framework allows you to easily recreate the standard settings pane UI within your own application by simply adding a SettingsChrome control into the pane’s XAML.&lt;/p&gt;&lt;p&gt;A sample application demonstrating the use of SettingsChrome, as well as how to define a settings pane using MVVM is available from the &lt;a href="http://okra.codeplex.com/releases/view/98887"&gt;Okra CodePlex downloads page&lt;/a&gt;.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/JyqWF3uS6P0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/4630369088731444699/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=4630369088731444699" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4630369088731444699?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4630369088731444699?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/JyqWF3uS6P0/creating-authentic-looking-settings.html" title="Creating Authentic Looking Settings Panes with SettingsChrome" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-aKsvonlOujQ/URAtglYltmI/AAAAAAAAAFI/2BiUBktDk-c/s72-c/SettingsPaneUI_thumb%25255B14%25255D.png?imgmax=800" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2013/02/creating-authentic-looking-settings.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEEQHo9eCp7ImA9WhNWF0U.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-5632982742199016755</id><published>2012-12-17T22:03:00.001Z</published><updated>2012-12-17T22:16:41.460Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-17T22:16:41.460Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="Okra" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><title>Settings Panes and the Okra App Framework</title><content type="html">&lt;p&gt;In this post (the first of two) I will describe how you can use the &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framework&lt;/a&gt; to add custom settings panes to your Windows Store application, in particular taking advantage of the MVVM pattern. In my following post I will show you how to easily design a settings UI consistent with the built-in Windows applications.&lt;/p&gt; &lt;p&gt;In Windows 8, application settings are available from any page of a running application by using the settings charm. This brings up a system-provided list of the available settings entry points, with application specific settings at the top (followed by the Windows provided “Permissions” and “Rate and review” items). If the user selects one of these application specified entry points it is the responsibility of the running application to provide the resulting settings UI.&lt;/p&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-0fBjA-M7j30/UM-WqkH9GsI/AAAAAAAAAEo/U1SD4sd2Jz4/s1600-h/Settings-images7.png"&gt;&lt;img title="Settings images" style="border-left-width: 0px; border-right-width: 0px; background-image: none; border-bottom-width: 0px; float: none; padding-top: 0px; padding-left: 0px; margin-left: auto; display: block; padding-right: 0px; border-top-width: 0px; margin-right: auto" border="0" alt="Settings images" src="http://lh6.ggpht.com/-PSv2Emc-MY4/UM-Wrmbs7DI/AAAAAAAAAEs/jb-__5PJV4g/Settings-images_thumb5.png?imgmax=800" width="240" height="191"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h2&gt;Defining a Settings Pane with the Okra App Framework&lt;/h2&gt; &lt;p&gt;The Okra App Framework makes it simple to add custom settings panes, following the same pattern as any other page within an Okra based application. The framework takes care of displaying the correct UI and providing a dedicated navigation stack within the settings pane.&lt;/p&gt; &lt;p&gt;Any element may be used to define the settings UI, however a UserControl is most commonly used. This is tagged with a page name using the PageExport attribute in the code-behind file.&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[PageExport(&lt;span style="color: #006080"&gt;"MySettings"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MySettingsPage : UserControl&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;If using the MVVM pattern, the view-model is similarly defined and attributed with the ViewModelExport attribute.&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[ViewModelExport(&lt;span style="color: #006080"&gt;"MySettings"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MySettingsViewModel : ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;This is all that is required to define an MVVM based settings pane.&lt;/p&gt;&lt;h2&gt;Displaying the Settings Pane&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Whenever a user opens the settings pane, the currently running application is notified via the ‘SettingsPane.CommandsRequested’ event and asked to return the settings to display. In Okra based applications the recommended place to register for this event is in the SetupServices() method of the application bootstrapper. In the event handler you can add any number of settings commands in the order they are desired.&lt;/p&gt;&lt;p&gt;The Okra App Framework provides an ISettingsManager interface and default implementation to handle the resulting navigation to a settings pane. By calling the ‘NavigateTo(…)’ method the settings UI will be displayed in a slide-in pane at the edge of the screen.&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; ISettingsPaneManager : INavigationBase&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ShowSettingsPane();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; INavigationBase&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;bool&lt;/span&gt; CanGoBack { get; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    INavigationEntry CurrentPage { get; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;event&lt;/span&gt; EventHandler CanGoBackChanged;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; GoBack();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; pageName);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; pageName, &lt;span style="color: #0000ff"&gt;object&lt;/span&gt; arguments);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;To make this even easier, the Okra App Framework provides a helper extension method on any INavigationBase instance named ‘GetNavigateToSettingsCommand(…)’ which takes as arguments the name to display to the user, and the page name we defined in the previous section. Therefore a typical bootstrapper will look as follows,&lt;/p&gt;&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; max-height: 600px; width: 97.5%; background-color: #f4f4f4"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; AppBootstrapper : OkraBootstrapper&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    &lt;span style="color: #008000"&gt;// *** Imported Properties ***&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    [Import]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; ISettingsPaneManager SettingsPaneManager { get; set; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;    &lt;span style="color: #008000"&gt;// *** Overriden Base Methods ***&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;    &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetupServices()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;        &lt;span style="color: #008000"&gt;// Register with Windows to display items in the settings pane&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width:180%;background-color: #f4f4f4"&gt;        SettingsPane.GetForCurrentView().CommandsRequested += SettingsPane_CommandsRequested;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    &lt;span style="color: #008000"&gt;// *** Private Methods ***&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SettingsPane_CommandsRequested(SettingsPane sender, SettingsPaneCommandsRequestedEventArgs args)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;        &lt;span style="color: #008000"&gt;// Add each settings item in the order you wish them to appear&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;        args.Request.ApplicationCommands.Add(SettingsPaneManager.GetNavigateToSettingsCommand(&lt;span style="color: #006080"&gt;"Settings"&lt;/span&gt;, &lt;span style="color: #006080"&gt;"MySettings"&lt;/span&gt;));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: white"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 180%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;h2&gt;Navigation Within the Settings Pane&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Whilst in many cases a custom settings pane will self contained, multi-page settings are possible. Consider an “Accounts” setting where a link takes you to a further “Add account” settings page. This is fully supported in the Okra App Framework by calling the ISettingsPaneManager.NavigateTo(…) and .GoBack() methods to navigate between sections. In addition, calling ‘GoBack()’ on the first page in the navigation stack will redisplay the system provided settings list.&lt;/p&gt;&lt;h2&gt;Summary&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;To summarise, the Okra App Framework makes adding settings panes to your application simple. The steps are,&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Create a UserControl with the desired UI and set the PageExport attribute.&lt;/li&gt;&lt;li&gt;Optionally add a view-model attributed with the ViewModelExport attribute.&lt;/li&gt;&lt;li&gt;In the application bootstrapper register for the SettingsPane.CommandsRequested event and use the GetNavigateToSettingsCommand(…) extension method to return a SettingsCommand.&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;A sample application demonstrating custom settings panes is available from the &lt;a href="http://okra.codeplex.com/releases/view/98887"&gt;Okra CodePlex downloads&lt;/a&gt;.&lt;/p&gt;&lt;p&gt;Of course it is up to you to provide a suitable UI for the displayed settings pane. In my next post I will describe how to use Okra’s SettingsChrome to present a UI consistent with the standard Windows experience.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/jgRfjK_PrgU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/5632982742199016755/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=5632982742199016755" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5632982742199016755?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5632982742199016755?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/jgRfjK_PrgU/settings-panes-and-okra-app-framework.html" title="Settings Panes and the Okra App Framework" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh6.ggpht.com/-PSv2Emc-MY4/UM-Wrmbs7DI/AAAAAAAAAEs/jb-__5PJV4g/s72-c/Settings-images_thumb5.png?imgmax=800" height="72" width="72" /><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/12/settings-panes-and-okra-app-framework.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkQNR3s-cSp7ImA9WhNREE4.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-301131914004050332</id><published>2012-11-04T13:06:00.001Z</published><updated>2012-11-04T13:06:36.559Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T13:06:36.559Z</app:edited><title>Okra App Framework v0.9.5 Released</title><content type="html">&lt;p&gt;The latest update to the Okra App Framework has just been released and is available from the Okra &lt;a href="http://okra.codeplex.com/"&gt;CodePlex&lt;/a&gt; site and via &lt;a href="http://www.nuget.org/Packages/Okra.MEF"&gt;NuGet&lt;/a&gt;.&lt;/p&gt; &lt;h2&gt;New Features in This Release&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;Settings support&lt;/li&gt; &lt;ul&gt; &lt;li&gt;The framework now includes support for the Windows 8 settings charm. Custom application settings panes can be defined using the MVVM pattern and Okra will handle the wiring required to show the settings pane – I will write about this in detail in an upcoming blog post.&lt;/li&gt; &lt;li&gt;A SettingsChrome control is included to allow developers to easily match the settings UI of the default Windows 8 applications&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;The NavigationManager class has now been refactored to derive from a NavigationBase class with the base functionality. This allows the creation of custom navigation managers (for example the SettingsPaneManager)&lt;/li&gt; &lt;li&gt;Updated to support MEF v1.0.16&lt;/li&gt; &lt;li&gt;Minor improvements and bug fixes&lt;/li&gt;&lt;/ul&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/6kRtcvro-qA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/301131914004050332/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=301131914004050332" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/301131914004050332?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/301131914004050332?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/6kRtcvro-qA/okra-app-framework-v095-released.html" title="Okra App Framework v0.9.5 Released" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/11/okra-app-framework-v095-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4CQHg4eSp7ImA9WhNSFUk.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-620862913173850512</id><published>2012-10-29T21:50:00.001Z</published><updated>2012-10-29T21:59:21.631Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-29T21:59:21.631Z</app:edited><title>App Search and the Okra App Framework</title><content type="html">&lt;p&gt;One advantage of the &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framework&lt;/a&gt; over other MVVM-based application frameworks is that it is designed from the ground up to work great with Windows 8. Over the next few versions this will become more evident as features are added to support the various Windows 8 system contracts – search, settings, sharing, etc.&lt;/p&gt; &lt;p&gt;In this post I will describe how the Okra App Framework makes it easy to add search to your application using the same MVVM principles that you are using for the rest of your application.&lt;/p&gt; &lt;h2&gt;The Search Contract in Windows 8&lt;/h2&gt; &lt;p&gt;When developing Windows Store applications many developers will want to take advantage of the Windows 8 search charm. This allows users to search across all applications from a single, consistent entry point. In order to add search functionality you would generally override the OnSearchActivated(…) method in the App.xaml.cs code-behind. In fact the standard Visual Studio search page template will add the code required to do this. For a great Windows Store application however you would want to,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Fully follow the Windows search design guidelines (available &lt;a href="http://msdn.microsoft.com/en-US/library/windows/apps/hh465233"&gt;here&lt;/a&gt;)&lt;/li&gt; &lt;li&gt;Preserve the existing application state and correctly handle back navigation from the search page&lt;/li&gt; &lt;li&gt;Navigate to a suitable page (normally the application home page) if an empty search is performed&lt;/li&gt; &lt;li&gt;Improve performance by attaching to the SearchPane.QuerySubmitted event where possible&lt;/li&gt; &lt;li&gt;You may also want to implement the search page using the MVVM pattern&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;By simply using the Okra App Framework search manager it will take care of these requirements.&lt;/p&gt; &lt;h2&gt;Adding Search to Your Application with the Okra App Framework&lt;/h2&gt; &lt;p&gt;The Okra App Framework provides a search manager to handle the process of activating search in your application. This is represented by the ISearchManager interface,&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; ISearchManager&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; SearchPageName { get; set; }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;By default the SearchPageName property is set to null, and Okra will not handle search activation. To opt-in to the search integration you should set the page name for search in your application’s bootstrapper SetupServices() method.&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; AppBootstrapper : OkraBootstrapper&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; SetupServices()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;        SearchManager.SearchPageName = &lt;span style="color: #006080"&gt;"Search"&lt;/span&gt;;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;By adding this single line your application has been enabled for search, and a page named “Search” will be navigated to when the user performs a search within your application (note that you will also need to declare that your application supports search in the application manifest).&lt;/p&gt;&lt;h2&gt;Defining Your Search Page&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;Because search uses the standard Okra page discovery mechanisms you define your search page and view-model as you would any other page within your application,&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[PageExport(&lt;span style="color: #006080"&gt;"Search"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SearchPage : LayoutAwarePage&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[ViewModelExport(&lt;span style="color: #006080"&gt;"Search"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SearchViewModel : NotifyPropertyChangedBase, ISearchPage&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;p&gt;One thing to note is that the search view model implements the ISearchPage interface (this could also be implemented by the page if you are not using the MVVM pattern),&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;interface&lt;/span&gt; ISearchPage&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; PerformQuery(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; queryText, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; language);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;This method will be called whenever the page should show a new set of search results. In this method you provide the application logic to perform the search operation and display the results to the user. Note that this may be called multiple times for a single page as the user performs subsequent searches and you should refresh the content with the new results.&lt;/p&gt;&lt;h2&gt;Summary&lt;/h2&gt;&lt;br /&gt;&lt;p&gt;In the above discussion I have shown how the &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framew&lt;/a&gt;ork makes it simple to implement search functionality in applications based on the MVVM pattern.&lt;/p&gt;&lt;p&gt;A sample search application is available from the &lt;a href="http://okra.codeplex.com/releases/view/96990"&gt;Okra CodePlex downloads section&lt;/a&gt;. This is based on the Visual Studio search template, but modified to correctly implement the MVVM pattern.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/jIfHFaoqLVo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/620862913173850512/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=620862913173850512" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/620862913173850512?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/620862913173850512?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/jIfHFaoqLVo/app-search-and-okra-app-framework.html" title="App Search and the Okra App Framework" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/10/app-search-and-okra-app-framework.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04ERnoycSp7ImA9WhJVGEo.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-422453132579873990</id><published>2012-09-05T22:11:00.001+01:00</published><updated>2012-09-05T22:18:27.499+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-05T22:18:27.499+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="Navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="Okra" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><title>Convention Based Page Discovery With The Okra App Framework</title><content type="html">&lt;p&gt;One of the key features of the &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framework&lt;/a&gt; for developing Windows 8 apps is the navigation framework with its support for the MVVM pattern. By default pages and view-models are marked with attributes so that the framework can locate them. In this post I will describe how you can enable an alternative convention based approach.&lt;/p&gt; &lt;h2&gt;The Default Attribute Based Approach&lt;/h2&gt; &lt;p&gt;When using the Okra App Framework navigation support all pages are represented by a page name. So that the framework can locate the associated pages and view-models these are normally attributed with either the PageExportAttribute or ViewModelExportAttribute respectively (for more information see &lt;a href="http://andyonwpf.blogspot.com/2012/04/navigation-in-cocoon-mvvm-for-metro.html"&gt;my previous post&lt;/a&gt;). For example for a page named “Foo” the classes would be attributed as,&lt;/p&gt; &lt;div id="codeSnippetWrapper"&gt; &lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[PageExport(&lt;span style="color: #006080"&gt;"Foo"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FooPage : LayoutAwarePage&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;[ViewModelExport(&lt;span style="color: #006080"&gt;"Foo"&lt;/span&gt;)]&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FooViewModel&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;A Convention Based Approach&lt;/h2&gt;&lt;p&gt;Often however there will be a common naming pattern throughout the application. In the example above all pages are named XxxPage and view-models named XxxViewModel, where “Xxx” is the associated page name. In a convention based approach you no longer need to apply attributes to classes. Instead they are automatically discovered based on a common naming system.&lt;/p&gt;&lt;p&gt;Since the standard Okra bootstrapper uses MEF for composition (for example when using the &lt;a href="http://www.nuget.org/Packages/Okra.MEF"&gt;Okra.MEF NuGet package&lt;/a&gt;), we can use the MEF convention based discovery. To enable this we need to add the following code to the application bootstrapper,&lt;/p&gt;&lt;div id="codeSnippetWrapper" style="overflow: auto; cursor: text; font-size: 8pt; border-top: silver 1px solid; font-family: 'Courier New', courier, monospace; border-right: silver 1px solid; border-bottom: silver 1px solid; padding-bottom: 4px; direction: ltr; text-align: left; padding-top: 4px; padding-left: 4px; margin: 20px 0px 10px; border-left: silver 1px solid; line-height: 12pt; padding-right: 4px; width: 97.5%; background-color: #f4f4f4"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; AppBootstrapper : OkraBootstrapper&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;    &lt;span style="color: #008000"&gt;// *** Overriden base methods ***&lt;/span&gt;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;    &lt;span style="color: #0000ff"&gt;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; ContainerConfiguration GetContainerConfiguration()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;    {&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;        ConventionBuilder conventionBuilder = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ConventionBuilder();&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;        conventionBuilder.ForTypesMatching(type =&amp;gt; type.FullName.EndsWith(&lt;span style="color: #006080"&gt;"Page"&lt;/span&gt;))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;                         .Export(builder =&amp;gt; builder.AsContractType&amp;lt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt;()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;                                                   .AsContractName(&lt;span style="color: #006080"&gt;"OkraPage"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;                                                   .AddMetadata(&lt;span style="color: #006080"&gt;"PageName"&lt;/span&gt;, type =&amp;gt; type.Name.Substring(0, type.Name.Length - 4)));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;        conventionBuilder.ForTypesMatching(type =&amp;gt; type.FullName.EndsWith(&lt;span style="color: #006080"&gt;"ViewModel"&lt;/span&gt;))&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;                         .Export(builder =&amp;gt; builder.AsContractType&amp;lt;&lt;span style="color: #0000ff"&gt;object&lt;/span&gt;&amp;gt;()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;                                                   .AsContractName(&lt;span style="color: #006080"&gt;"OkraViewModel"&lt;/span&gt;)&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;                                                   .AddMetadata(&lt;span style="color: #006080"&gt;"PageName"&lt;/span&gt;, type =&amp;gt; type.Name.Substring(0, type.Name.Length - 9)));&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;        &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; GetOkraContainerConfiguration()&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;                .WithAssembly(&lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(AppBootstrapper).GetTypeInfo().Assembly, conventionBuilder);&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: white"&gt;    }&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 200%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;p&gt;With this code in place we can greatly simplify our page and view-model definitions to the following. Note that since we follow the convention we no longer need to add any attributes.&lt;/p&gt;&lt;div id="codeSnippetWrapper"&gt;&lt;div id="codeSnippet" style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;sealed&lt;/span&gt; &lt;span style="color: #0000ff"&gt;partial&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FooPage : LayoutAwarePage&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;&amp;nbsp;&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;&lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; FooViewModel&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;{&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: #f4f4f4"&gt;    ...&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;pre style="border-top-style: none; overflow: visible; font-size: 8pt; border-left-style: none; font-family: 'Courier New', courier, monospace; border-bottom-style: none; color: black; padding-bottom: 0px; direction: ltr; text-align: left; padding-top: 0px; border-right-style: none; padding-left: 0px; margin: 0em; line-height: 12pt; padding-right: 0px; width: 100%; background-color: white"&gt;}&lt;/pre&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;/div&gt;&lt;h2&gt;Summary&lt;/h2&gt;&lt;p&gt;As I have shown, when using the &lt;a href="http://okra.codeplex.com/"&gt;Okra App Framework&lt;/a&gt; navigation support you can simplify app development by using a convention based approach to defining pages and view-models for the MVVM pattern.&lt;/p&gt;&lt;p&gt;A sample application demonstrating this is available from the &lt;a href="http://okra.codeplex.com/releases/view/94066"&gt;Okra CodePlex downloads&lt;/a&gt;.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/7m9r_dtRGgw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/422453132579873990/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=422453132579873990" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/422453132579873990?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/422453132579873990?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/7m9r_dtRGgw/convention-based-page-discovery-with.html" title="Convention Based Page Discovery With The Okra App Framework" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/09/convention-based-page-discovery-with.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UERnw5cCp7ImA9WhJVEEQ.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-2039391601285398275</id><published>2012-08-27T21:26:00.001+01:00</published><updated>2012-08-27T21:26:47.228+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-27T21:26:47.228+01:00</app:edited><title>Okra App Framework v0.9.4 Released</title><content type="html">&lt;p&gt;Version 0.9.4 of the Okra App Framework is now available via &lt;a href="http://okra.codeplex.com/"&gt;CodePlex&lt;/a&gt; and &lt;a href="http://www.nuget.org/Packages/Okra.MEF"&gt;NuGet&lt;/a&gt;. Since the core functionality of the framework has been in testing for some time now I have removed the ‘beta’ suffix from the version number, with the benefit that the framework should show in the default NuGet feed.&lt;/p&gt; &lt;p&gt;Minimal changes and bug fixes were made in this release, with the key change being updating the Okra App Framework to work against the RTM version of MEF (v1.0.15).&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/UPyVCGizfGk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/2039391601285398275/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=2039391601285398275" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/2039391601285398275?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/2039391601285398275?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/UPyVCGizfGk/okra-app-framework-v094-released.html" title="Okra App Framework v0.9.4 Released" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/08/okra-app-framework-v094-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak4GR3c8eCp7ImA9WhJXF0Q.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-8222132155205207891</id><published>2012-08-12T20:15:00.001+01:00</published><updated>2012-08-12T20:15:26.970+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-12T20:15:26.970+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="Okra" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Cocoon is now the Okra App Framework</title><content type="html">&lt;p&gt;Today I would like to announce that the Cocoon framework is now know as the ‘Okra App Framework’. It still includes the great features previously available in the Cocoon framework, but from now onwards will be developed under the new name.&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;How to Get The Okra App Framework&lt;/h2&gt; &lt;p&gt;The ‘Okra App Framework’ CodePlex site is available at &lt;a href="http://okra.codeplex.com/"&gt;http://okra.codeplex.com/&lt;/a&gt; (all previous code/downloads/discussions have been migrated from the old site, and any links to the previous URLs will redirect to their new location).&lt;/p&gt; &lt;p&gt;In addition there are two new NuGet packages,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="https://www.nuget.org/packages/Okra.MEF"&gt;“Okra App Framework”&lt;/a&gt; – This will be the package for most users and includes the MEF dependencies and the ‘OkraBootstrapper’ class.  &lt;li&gt;&lt;a href="https://www.nuget.org/packages/Okra.Core"&gt;“Okra App Framework (Core only)”&lt;/a&gt; – For users who only require the core assembly.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;If you are using the Cocoon NuGet packages and wish to get future releases then you should use the NuGet package manager to uninstall Cocoon and then install the new Okra App Framework package.&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;Okra App Framework Release 0.9.3-beta&lt;/h2&gt; &lt;p&gt;Along with the name change a new version of the framework has been released via NuGet and the &lt;a href="http://okra.codeplex.com/releases/"&gt;Okra App Framework CodePlex downloads page&lt;/a&gt;. The changes include,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Namespace changes from ‘Cocoon’ to ‘Okra’ and from ‘CocoonBootstrapper’ to ‘OkraBootstrapper’ (a simple find-and-replace in your project should solve any errors occurring from this). &lt;li&gt;Addition of a SearchManager that allows an easy, view-model centric, implementation of the Windows 8 Search contract (I will aim to detail this in a future blog post). &lt;li&gt;The ActivationManager class allows extensible handling of application activation (you can write activation handlers to handle any of the activation types). &lt;li&gt;Upgraded to MEF version 1.0.13-rc. &lt;li&gt;Removal of the previous obsoleted VirtualizingVector with the recommendation that VirtualizingVectorBase is used going forward (although if you still require VirtualizingVector it can be downloaded as part of any of the previous source releases and copied into your own projects).&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Why the Name Change?&lt;/h2&gt; &lt;p&gt;I recently received a message from a member of the Apache Software Foundation, informing me that they also have a web application framework named &lt;a href="http://projects.apache.org/projects/cocoon.html"&gt;Apache Cocoon&lt;/a&gt;. To avoid any confusion that may arise between the two frameworks the best approach going forward was a name change.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/4bT3vHJiK4Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/8222132155205207891/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=8222132155205207891" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/8222132155205207891?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/8222132155205207891?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/4bT3vHJiK4Q/cocoon-is-now-okra-app-framework.html" title="Cocoon is now the Okra App Framework" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/08/cocoon-is-now-okra-app-framework.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMAQ3g_eip7ImA9WhJXEkU.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-5237223746671526815</id><published>2012-08-06T21:01:00.001+01:00</published><updated>2012-08-06T21:04:02.642+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-06T21:04:02.642+01:00</app:edited><title>Shell Based Navigation in Cocoon</title><content type="html">I recently had a query in the &lt;a href="http://cocoon.codeplex.com/discussions"&gt;Cocoon CodePlex forums&lt;/a&gt; regarding how to support an application shell when using the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt;’s navigation support. By default the Cocoon navigation framework will display pages full screen, with each navigation replacing the previous page with the next. There are some occasions however where it makes sense to have an application shell that takes up the full screen, with the page navigation occurring in a region within this.&lt;br /&gt;
&lt;br /&gt;
A typical example would consist of a fixed region dedicated to navigation at the top of the screen, with the page content filling below. The end result looks like,&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://lh4.ggpht.com/-blKO6ONLssI/UCAipWpGKpI/AAAAAAAAAEE/LizXT2CMy4I/s1600-h/image%25255B11%25255D.png"&gt;&lt;img alt="image" border="0" height="250" src="http://lh4.ggpht.com/-0y5emQDbE9M/UCAiqX_eAWI/AAAAAAAAAEI/fRv3poxybYM/image_thumb%25255B6%25255D.png?imgmax=800" style="background-image: none; border: 0px currentColor; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="400" /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h2&gt;
&lt;/h2&gt;
&lt;h2&gt;
Creating an Application Shell in Cocoon&lt;/h2&gt;
The key to creating an application shell in Cocoon is the INavigationTarget interface. This has only a single method named NavigateTo(…). When implemented by an application, any calls to the navigation framework will result in a call to this method with the page to display. The framework itself will handle the creation and wiring up of views and view-models, the navigation stack, persistence and other aspects of navigation.&lt;br /&gt;
In our example application we will use the MVVM pattern to define our application shell, hence we have a ShellViewModel,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt;   1:&lt;/span&gt; [Export(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(INavigationTarget))]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt;   2:&lt;/span&gt; [Shared]&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt;   3:&lt;/span&gt; &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; ShellViewModel : NotifyPropertyChangedBase, INavigationTarget&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt;   5:&lt;/span&gt;     &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt;   6:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt;   7:&lt;/span&gt;     &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;object&lt;/span&gt; content;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt;   8:&lt;/span&gt;     &lt;span style="color: blue;"&gt;private&lt;/span&gt; ShellPage shellPage;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt;   9:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt;  10:&lt;/span&gt;     &lt;span style="color: green;"&gt;// *** Properties ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt;  11:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt;  12:&lt;/span&gt;     &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;object&lt;/span&gt; Content&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt;  13:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt;  14:&lt;/span&gt;         get&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum15" style="color: #606060;"&gt;  15:&lt;/span&gt;         {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum16" style="color: #606060;"&gt;  16:&lt;/span&gt;             &lt;span style="color: blue;"&gt;return&lt;/span&gt; content;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum17" style="color: #606060;"&gt;  17:&lt;/span&gt;         }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum18" style="color: #606060;"&gt;  18:&lt;/span&gt;         set&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum19" style="color: #606060;"&gt;  19:&lt;/span&gt;         {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum20" style="color: #606060;"&gt;  20:&lt;/span&gt;             &lt;span style="color: blue;"&gt;if&lt;/span&gt; (content != &lt;span style="color: blue;"&gt;value&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum21" style="color: #606060;"&gt;  21:&lt;/span&gt;             {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum22" style="color: #606060;"&gt;  22:&lt;/span&gt;                 content = &lt;span style="color: blue;"&gt;value&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum23" style="color: #606060;"&gt;  23:&lt;/span&gt;                 OnPropertyChanged();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum24" style="color: #606060;"&gt;  24:&lt;/span&gt;             }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum25" style="color: #606060;"&gt;  25:&lt;/span&gt;         }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum26" style="color: #606060;"&gt;  26:&lt;/span&gt;     }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum27" style="color: #606060;"&gt;  27:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum28" style="color: #606060;"&gt;  28:&lt;/span&gt;     &lt;span style="color: green;"&gt;// *** INavigationTarget Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum29" style="color: #606060;"&gt;  29:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum30" style="color: #606060;"&gt;  30:&lt;/span&gt;     &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: blue;"&gt;object&lt;/span&gt; page)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum31" style="color: #606060;"&gt;  31:&lt;/span&gt;     {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum32" style="color: #606060;"&gt;  32:&lt;/span&gt;         &lt;span style="color: green;"&gt;// If this is the first navigation then create the shell view and bind to this view model&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum33" style="color: #606060;"&gt;  33:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum34" style="color: #606060;"&gt;  34:&lt;/span&gt;         &lt;span style="color: blue;"&gt;if&lt;/span&gt; (shellPage == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum35" style="color: #606060;"&gt;  35:&lt;/span&gt;         {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum36" style="color: #606060;"&gt;  36:&lt;/span&gt;             shellPage = &lt;span style="color: blue;"&gt;new&lt;/span&gt; ShellPage();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum37" style="color: #606060;"&gt;  37:&lt;/span&gt;             shellPage.DataContext = &lt;span style="color: blue;"&gt;this&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum38" style="color: #606060;"&gt;  38:&lt;/span&gt;         }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum39" style="color: #606060;"&gt;  39:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum40" style="color: #606060;"&gt;  40:&lt;/span&gt;         &lt;span style="color: green;"&gt;// Set the content for the shell to the specified page&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum41" style="color: #606060;"&gt;  41:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum42" style="color: #606060;"&gt;  42:&lt;/span&gt;         &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Content = page;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum43" style="color: #606060;"&gt;  43:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum44" style="color: #606060;"&gt;  44:&lt;/span&gt;         &lt;span style="color: green;"&gt;// Set the shell view as the window content&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum45" style="color: #606060;"&gt;  45:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum46" style="color: #606060;"&gt;  46:&lt;/span&gt;         Window.Current.Content = shellPage;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum47" style="color: #606060;"&gt;  47:&lt;/span&gt;     }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum48" style="color: #606060;"&gt;  48:&lt;/span&gt; }&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
The ShellViewModel exposes a single property named ‘Content’ that will contain the page to display and will be bound to in the view. In our NavigateTo(…) method we firstly determine if we have created the associated view and create this is necessary. We then set the ‘Content’ property to the supplied page and this ensure that the view is displayed in the window. Finally we mark the class as a shared export of INavigationTarget using the MEF attributes. Note that since we will never be navigating explicitly to the shell then we do not need to decorate this with a ViewModelExport attribute.&lt;br /&gt;
&lt;br /&gt;
In the sample code the shell view model also exposes a ‘GoBackCommand’ that allows you to include a back navigation button within the shell region.&lt;br /&gt;
&lt;br /&gt;
The ShellPage.xaml file contains the view for the application shell. This simply contains the required elements for the upper portion of the screen, with a ContentControl bound to the view models ‘Content’ property. It is within this ContentControl that the pages will be displayed. The key elements are shown below,&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum1" style="color: #606060;"&gt;   1:&lt;/span&gt; &amp;lt;Grid Style=&lt;span style="color: #006080;"&gt;"{StaticResource LayoutRootStyle}"&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum2" style="color: #606060;"&gt;   2:&lt;/span&gt;     ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum3" style="color: #606060;"&gt;   3:&lt;/span&gt;&amp;nbsp; &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum4" style="color: #606060;"&gt;   4:&lt;/span&gt;     &amp;lt;!-- Back button and page title --&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum5" style="color: #606060;"&gt;   5:&lt;/span&gt;     &amp;lt;Grid&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum6" style="color: #606060;"&gt;   6:&lt;/span&gt;         &amp;lt;Grid.ColumnDefinitions&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum7" style="color: #606060;"&gt;   7:&lt;/span&gt;             &amp;lt;ColumnDefinition Width=&lt;span style="color: #006080;"&gt;"Auto"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum8" style="color: #606060;"&gt;   8:&lt;/span&gt;             &amp;lt;ColumnDefinition Width=&lt;span style="color: #006080;"&gt;"*"&lt;/span&gt;/&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum9" style="color: #606060;"&gt;   9:&lt;/span&gt;         &amp;lt;/Grid.ColumnDefinitions&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum10" style="color: #606060;"&gt;  10:&lt;/span&gt;         &amp;lt;Button x:Name=&lt;span style="color: #006080;"&gt;"backButton"&lt;/span&gt; .../&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum11" style="color: #606060;"&gt;  11:&lt;/span&gt;         &amp;lt;TextBlock x:Name=&lt;span style="color: #006080;"&gt;"pageTitle"&lt;/span&gt; .../&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum12" style="color: #606060;"&gt;  12:&lt;/span&gt;     &amp;lt;/Grid&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum13" style="color: #606060;"&gt;  13:&lt;/span&gt;     &amp;lt;ContentControl Content=&lt;span style="color: #006080;"&gt;"{Binding Content}"&lt;/span&gt; .../&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span id="lnum14" style="color: #606060;"&gt;  14:&lt;/span&gt; &amp;lt;/Grid&amp;gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
When the application is run the NavigationManager will automatically locate the INavigationTarget through the MEF export and direct all navigation through this.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Summary&lt;/h2&gt;
I have shown above how you can implement an application shell using the Cocoon framework. The sample application with full source code is available from the &lt;a href="http://cocoon.codeplex.com/releases/view/91893"&gt;Cocoon CodePlex downloads&lt;/a&gt;.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/JlTfIA7BCMs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/5237223746671526815/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=5237223746671526815" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5237223746671526815?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5237223746671526815?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/JlTfIA7BCMs/shell-based-navigation-in-cocoon.html" title="Shell Based Navigation in Cocoon" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://lh4.ggpht.com/-0y5emQDbE9M/UCAiqX_eAWI/AAAAAAAAAEI/fRv3poxybYM/s72-c/image_thumb%25255B6%25255D.png?imgmax=800" height="72" width="72" /><thr:total>1</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/08/shell-based-navigation-in-cocoon.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EFQ3g_fCp7ImA9WhJQEUs.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-6185780383577603091</id><published>2012-07-24T21:26:00.001+01:00</published><updated>2012-07-24T21:26:52.644+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-07-24T21:26:52.644+01:00</app:edited><title>Cocoon Framework v0.9.2 Released</title><content type="html">&lt;p&gt;As I discussed in my &lt;a href="http://andyonwpf.blogspot.com/2012/06/cocoon-now-available-on-nuget.html"&gt;previous post&lt;/a&gt; on NuGet support in the Cocoon framework, I will be distributing major updates within the framework as new releases. Today I am pleased to say that version 0.9.2 is available from both the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; and downloadable &lt;a href="http://www.nuget.org/packages/Cocoon.MEF"&gt;directly from NuGet&lt;/a&gt;.&lt;/p&gt; &lt;h2&gt;New Features in This Release&lt;/h2&gt; &lt;p&gt;This release has mainly focussed upon updates to the Cocoon data framework. In particular,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Significant improvements in how the data framework handles caching of list items.&lt;/li&gt; &lt;li&gt;Infrastructure added to support change notifications for data lists.&lt;/li&gt; &lt;li&gt;The ‘PagedDataListSource’ class now includes a ‘PageCacheSize’ property that allows you to specify the maximum number of pages to hold in memory at any one time (by default all pages are stored).&lt;/li&gt; &lt;li&gt;Introduction of an ‘IncrementalLoadingDataList’ class. This supports the Windows 8 Metro &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh701916.aspx"&gt;ISupportIncrementalLoading&lt;/a&gt; interface. This allows a data bound UI to download a small subset of a large list of items, with further items being retrieved and added when the user scrolls to the end of the list.&lt;/li&gt; &lt;li&gt;A Refresh() method has been added to SimpleDataListSource and PagedDataListSource. This allows you to clear the internal cache and re-fetch any data that may have changed. Any attached data lists will automatically update to reflect the changes.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Some improvements to the navigation framework include,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Updated to support MEF version 1.0.11-rc.&lt;/li&gt; &lt;li&gt;Changes to the ‘CocoonBootstrapper’ to help with a convention based approach to exporting pages and view models (I will write a blog post on this in the future).&lt;/li&gt; &lt;li&gt;The navigation manager now exposes a ‘CurrentPage’ property so that you can programmatically determine the currently displayed page and associated information.&lt;/li&gt; &lt;li&gt;Pages and view-models can now be named by specifying a type as an alternative to a string page name.&lt;/li&gt; &lt;li&gt;A MEF sharing boundary (named “page”) has been placed around each page and view model pair (see &lt;a href="http://mef.codeplex.com/wikipage?title=Sharing%20and%20lifetime"&gt;here&lt;/a&gt; for more information on MEF sharing boundaries).&lt;/li&gt; &lt;li&gt;Some common MVVM base classes have been included. Whilst you are not restricted to using these to take advantage of the Cocoon framework they provide basic functionality that is common to many applications. These classes include,&lt;/li&gt; &lt;ul&gt; &lt;li&gt;DelegateCommand and DelegateCommand&amp;lt;T&amp;gt; – implementations of the ICommand interface that allow you to bind UI interactions to methods on your view models.&lt;/li&gt; &lt;li&gt;NotifyPropertyChangedBase – provides a simple base class for view models that supports property change notification.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;A number of other bug fixes.&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Breaking Changes&lt;/h2&gt; &lt;p&gt;Unfortunately there are a small number of breaking changes in this release. For most developers however the changes should be minimal.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;‘SpecialPageNames.HomePage’ has been renamed ‘SpecialPageNames.Home’.&lt;/li&gt; &lt;li&gt;The contract for IDataListSource has changed. Note that this should only affect developers who are writing custom IDataListSource implementations. If you are using SimpleDataListSource or PagedDataListSource then existing code should not be affected. In particular the changes are,&lt;/li&gt; &lt;ul&gt; &lt;li&gt;Addition of an IndexOf(…) method to the IDataListSource interface.&lt;/li&gt; &lt;li&gt;The data list source implementations are now fully responsible for caching of data.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;The ‘InternalList’ property of ‘DataListSourceBase’ has been removed (derived classes should create their own internal cache) and the corresponding property in ‘SimpleDataListSource’ and ‘PagedDataListSource’ has been made private.&lt;/li&gt; &lt;li&gt;VirtualizingVector&amp;lt;T&amp;gt; is now marked as Obsolete – it is recommended that you use the data list support or the new VirtualizingVectorBase&amp;lt;T&amp;gt;.&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Getting the Latest Version of Cocoon&lt;/h2&gt; &lt;p&gt;To get the latest release of the Cocoon framework the best place to start is using the NuGet package manager to download the “Cocoon Framework” package (see &lt;a href="http://andyonwpf.blogspot.com/2012/06/cocoon-now-available-on-nuget.html"&gt;here&lt;/a&gt; for more information). If you are already using Cocoon via NuGet then you should be able to update your solution to the latest version directly through the NuGet package manager.&lt;/p&gt; &lt;p&gt;Alternatively the source code is available via the &lt;a href="http://cocoon.codeplex.com/releases/"&gt;Cocoon CodePlex downloads page&lt;/a&gt;. As always the latest interim code drops are also available from CodePlex under the source code tab.&lt;/p&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/jO_WuZ-qEFw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/6185780383577603091/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=6185780383577603091" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/6185780383577603091?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/6185780383577603091?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/jO_WuZ-qEFw/cocoon-framework-v092-released.html" title="Cocoon Framework v0.9.2 Released" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/07/cocoon-framework-v092-released.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUAFRXw7eCp7ImA9WhBXEUk.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-3560698074353943077</id><published>2012-06-26T22:36:00.001+01:00</published><updated>2013-03-24T16:48:34.200Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-24T16:48:34.200Z</app:edited><title>Cocoon Now Available on NuGet</title><content type="html">&lt;b&gt;Update : The 'Cocoon' framework is now named the 'Okra App Framework'. For information on how to obtain the framework via NuGet then see the documentation &lt;a href="http://okra.codeplex.com/wikipage?title=Downloading%20the%20Okra%20App%20Framework&amp;referringTitle=Documentation"&gt;here.&lt;/a&gt;&lt;/b&gt;

&lt;hr/&gt;

I am very pleased to announce that the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; is now available via NuGet (thanks to Brendan Forster for helping to get this off the ground). Going forward this will be the recommended source when using the framework in your own projects.&lt;br /&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

Getting Cocoon Via NuGet&lt;/h2&gt;
With the release of Visual Studio 2012, the NuGet package manager is included within the product. This means that to reference the Cocoon framework all you need to do is to right-click on the project’s “References” folder and select “Manage NuGet Packages…”&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-vKnS2JWUt8s/T-oq1cUTx4I/AAAAAAAAADs/bhx0i654F4U/s1600/NuGet+Menu+Option.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="238" src="http://3.bp.blogspot.com/-vKnS2JWUt8s/T-oq1cUTx4I/AAAAAAAAADs/bhx0i654F4U/s320/NuGet+Menu+Option.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
Note that since the Cocoon framework is currently pre-release then you should select “Include Prerelease” in the box highlighted in red below. You can then search for “Cocoon”.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-8N1AKX_88Eo/T-oq0K1h8uI/AAAAAAAAADg/7821SBVpW-Y/s1600/NuGet+Cocoon+Packages.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="265" src="http://4.bp.blogspot.com/-8N1AKX_88Eo/T-oq0K1h8uI/AAAAAAAAADg/7821SBVpW-Y/s400/NuGet+Cocoon+Packages.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
Note that there are currently two packages for the Cocoon framework. In general you should select the package named “Cocoon Framework” as this includes the complete framework including the MEF based bootstrapper. Clicking install will then download Cocoon along with any dependencies and add these to your project.&lt;br /&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

&lt;/h2&gt;
&lt;h2&gt;

Updating Your Project to the Latest Version Of the Cocoon Framework&lt;/h2&gt;
One of the advantages of using NuGet to distribute the Cocoon framework is that it makes it very easy to upgrade projects to the latest version of the framework. To do this simply open the package manager for a project that you have previously added Cocoon via NuGet and select the “Updates” tab. Any updated packages will be displayed and can be upgraded with a single click.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/-B6kPKy7MLkQ/T-oq0lCvcOI/AAAAAAAAADk/I1oOFvxyny4/s1600/NuGet+Cocoon+Updates.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="266" src="http://2.bp.blogspot.com/-B6kPKy7MLkQ/T-oq0lCvcOI/AAAAAAAAADk/I1oOFvxyny4/s400/NuGet+Cocoon+Updates.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;

Note: Making the Cocoon Framework Independent of Composition Container&lt;/h2&gt;
I have had a number of queries from developers who wish to use alternative composition containers with the Cocoon framework. Whilst it is recommended for most projects that you use the provided MEF composition implementation, with this latest release the Cocoon framework can now be used with any other composition container. The project has been split into two assemblies,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Cocoon – contains the core framework independent of composition container.  &lt;/li&gt;
&lt;li&gt;Cocoon.MEF – contains the MEF dependencies (most importantly the MEF based “CocoonBootstrapper”).&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;

How Will Cocoon be Released in the Future?&lt;/h2&gt;
Going forward there will be three ways to obtain the Cocoon framework,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;NuGet: This is the recommended source and will contain the latest stable versions. If I discuss any functionality on this blog then it will be implemented in the latest NuGet release unless otherwise stated.  &lt;/li&gt;
&lt;li&gt;&lt;a href="http://cocoon.codeplex.com/releases/"&gt;CodePlex Downloads&lt;/a&gt;: I will also provide a zipped package of the source code via CodePlex in the Cocoon downloads section. This will be kept in sync with the NuGet releases.  &lt;/li&gt;
&lt;li&gt;&lt;a href="http://cocoon.codeplex.com/SourceControl/list/changesets"&gt;CodePlex Source Control&lt;/a&gt;: For those interested in the very latest versions of Cocoon then this will be available as always via the “Source Code” tab of the Cocoon CodePlex site. Note however that this may include experimental functionality and may not be stable.&lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/qLpB4Kbtpfw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/3560698074353943077/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=3560698074353943077" title="3 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/3560698074353943077?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/3560698074353943077?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/qLpB4Kbtpfw/cocoon-now-available-on-nuget.html" title="Cocoon Now Available on NuGet" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-vKnS2JWUt8s/T-oq1cUTx4I/AAAAAAAAADs/bhx0i654F4U/s72-c/NuGet+Menu+Option.png" height="72" width="72" /><thr:total>3</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/06/cocoon-now-available-on-nuget.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE4FQ3Y8eyp7ImA9WhVaEEw.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-4349951767731668187</id><published>2012-06-06T22:08:00.001+01:00</published><updated>2012-06-06T22:08:32.873+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-06T22:08:32.873+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Cocoon Updated for Windows 8 Release Preview</title><content type="html">&lt;p&gt;You will be pleased to hear that I have just pushed an updated version of the Cocoon framework onto CodePlex that supports the Windows 8 Release Preview.&lt;/p&gt; &lt;p&gt;As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link). &lt;/p&gt; &lt;h2&gt;Using MEF in the Release Preview&lt;/h2&gt; &lt;p&gt;As many of you will be aware, the Cocoon framework uses the Managed Extensibility Framework (MEF) by default for locating and composing applications. With the release of the Windows 8 Release Preview, MEF is not being distributed separately – for more details see the &lt;a href="http://blogs.msdn.com/b/bclteam/archive/2012/05/30/mef-and-tpl-dataflow-nuget-packages-for-net-framework-4-5-rc.aspx"&gt;announcement on the BCL team blog&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;You will therefore need to add MEF as a reference to your application via NuGet. The above link has more details however the steps are,&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Right click on your projects ‘References’ folder and select “Manage NuGet Packages…”&lt;/li&gt; &lt;li&gt;Select “Online” in the left-hand pane and make sure that you have “Include Prerelease” selected rather then “Stable Only” at the top.&lt;/li&gt; &lt;li&gt;Use the search box to search for “MEF”&lt;/li&gt; &lt;li&gt;Select “MEF for web and Metro style apps” and click “Install”&lt;/li&gt;&lt;/ol&gt; &lt;h2&gt;Changes in tHis Release of Cocoon&lt;/h2&gt; &lt;p&gt;In general most applications should not be affected by the changes in this version of Cocoon (apart for the fact that they will run on the Release Preview!). Changes of interest include,&lt;/p&gt; &lt;ul&gt; &lt;li&gt;All use of MEF has been modified to support the new version&lt;/li&gt; &lt;li&gt;The ‘CocoonBootstrapper’ no longer has an overridable GetPartCatalog() method and is replaced with GetContainerConfiguration().&lt;/li&gt; &lt;li&gt;The ISupportPlaceholder interface has been removed in the Release Preview. The VirtualizingVector&amp;lt;T&amp;gt; implementation has been updated to reflect these changes and now returns ‘null’ as a placeholder (as now expected by the standard XAML controls).&lt;/li&gt; &lt;li&gt;Many other updates and bug fixes&lt;/li&gt;&lt;/ul&gt;  &lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/uzfM1zS7eIk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/4349951767731668187/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=4349951767731668187" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4349951767731668187?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4349951767731668187?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/uzfM1zS7eIk/cocoon-updated-for-windows-8-release.html" title="Cocoon Updated for Windows 8 Release Preview" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/06/cocoon-updated-for-windows-8-release.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkEDQXY-fyp7ImA9WhVbF0w.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-4049612100847102570</id><published>2012-05-29T19:25:00.001+01:00</published><updated>2012-06-03T11:17:50.857+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-06-03T11:17:50.857+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="Navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Cocoon Navigation – Making Your App “Always Alive”</title><content type="html">Over the last few posts I have discussed the navigation framework that is included as part of the freely available &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; for developing Metro-style Windows 8 applications in .Net languages. I have shown &lt;a href="http://andyonwpf.blogspot.com/2012/04/navigation-in-cocoon-mvvm-for-metro.html"&gt;how to annotate pages to be discovered by the framework&lt;/a&gt; and &lt;a href="http://andyonwpf.blogspot.com/2012/05/cocoon-navigation-passing-arguments.html"&gt;how to pass arguments between pages&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In this post I will discuss one of the benefits of using the Cocoon framework to manage your application’s navigation.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Making Your Application “Always Alive”&lt;/h2&gt;
One of the challenges when writing Windows 8 Metro-style applications is to manage the application lifecycle. So that Windows is able to ensure a great experience for users running on battery powered devices, Metro style apps are suspended as the user moves to other applications. Furthermore, your application may be terminated to free more memory if this is required. However for the end user great Metro-style applications will give the impression that they are “always alive” in the background. It is up to you, the developer, to ensure that this illusion is maintained. For more background Microsoft’s Windows 8 Application Developer blog has &lt;a href="http://blogs.msdn.com/b/windowsappdev/archive/2012/04/10/managing-app-lifecycle-so-your-apps-feel-quot-always-alive-quot.aspx"&gt;a great post on this topic&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
One aspect of making your application feel “always alive” is to ensure that if it is terminated and later relaunched then the user is taken to exactly the same point that they were previously viewing. To do this you must persist the navigation stack, currently viewed page and any page state then subsequently restore this.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Persisting Navigation With the Cocoon Framework&lt;/h2&gt;
The great news is that if you are using the Cocoon navigation framework then this is all handled automatically for you. All you have to do is enable this by setting the INavigationManager.NavigationStorageType property. Typically you would set this by overrinding the SetupNavigationManager() method in your application bootstrapper (&lt;a href="http://andyonwpf.blogspot.com/2012/05/getting-started-with-cocoon-navigation.html"&gt;see this post for more information on the bootstrapper&lt;/a&gt;),&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; AppBootstrapper : CocoonBootstrapper&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Overriden base methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; SetupNavigationManager()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        NavigationManager.NavigationStorageType = NavigationStorageType.Local;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
There are currently three possible NavigationStorageType values,&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;None – Your navigation state will not be persisted and your application will always launch to your home page.&lt;/li&gt;
&lt;br /&gt;
&lt;li&gt;Local – Your navigation state will be persisted to the current machine only.&lt;/li&gt;
&lt;br /&gt;
&lt;li&gt;Roaming – Your navigation state will be persisted between all devices that the user logs into using their Microsoft Account.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
That’s all you need to do, Cocoon will handle everything else – persisting the navigation stack, restoring to the correct page, storing the arguments passed to each page.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Preserving Page State&lt;/h2&gt;
In some cases you may want to go a step further and store some page state. Imagine for example you are half way through writing a comment in a social networking app, then change app to do something else. When you return you should expect that you can continue from where you left off. Other things you may want to preserve are selected search filters, selected items, position in a view, etc.&lt;br /&gt;
&lt;br /&gt;
Preserving page state can be done by the view model implementing the IActivatable&amp;lt;TArguments, TState&amp;gt; interface that &lt;a href="http://andyonwpf.blogspot.com/2012/05/cocoon-navigation-passing-arguments.html"&gt;I discussed last time for passing arguments to pages&lt;/a&gt;. The TState generic type can be set to the data type you would like to persist (TArguments can be set to ‘string’ if it is not required).&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; IActivatable&amp;lt;TArguments, TState&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; Activate(TArguments arguments, TState state);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    TState SaveState();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
On first navigation to the page the Activate(…) method will be called passing the default value of TState (‘null’ for string or reference types). When Cocoon determines that it should preserve page state then it will call the SaveState() method and your implementation should return the current state. If the application is later terminated and relaunched then a new instance of the view model is created and activated by calling the Activate(…) method with the preserved state.&lt;br /&gt;
&lt;br /&gt;
For example, if as part of a hypothetical photo browsing app we allow the user to comment on a photo we could implement the view model as,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[ViewModelExport(&lt;span style="color: #006080;"&gt;"ViewPhoto"&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; ViewPhotoViewModel : IActivatable&amp;lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;, ViewPhotoState&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Properties ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; Comment&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        get { ... }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        set { ... }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** IActivatable Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Activate(&lt;span style="color: blue;"&gt;string&lt;/span&gt; arguments, ViewPhotoState state)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Photo = GetPhoto(arguments);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;if&lt;/span&gt; (state != null)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            ViewPhotoState viewState = (ViewPhotoState)state;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Comment = viewState.Comment;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; ViewPhotoState SaveState()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; ViewPhotoState() { Comment = &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Comment };&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Sub-classes ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    [DataContract]&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; ViewPhotoState&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        [DataMember]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; Comment;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Note that we store the state as a custom ‘ViewPhotoState’ object that is decorated to allow serialization by the DataContractSerializer.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Summary&lt;/h2&gt;
&lt;br /&gt;
I have shown above how we can easily make our applications feel “always alive” by using the Cocoon navigation framework.&lt;br /&gt;
&lt;br /&gt;
As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/vFyJczFfPTk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/4049612100847102570/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=4049612100847102570" title="5 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4049612100847102570?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/4049612100847102570?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/vFyJczFfPTk/cocoon-navigation-making-your-app.html" title="Cocoon Navigation – Making Your App “Always Alive”" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>5</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/05/cocoon-navigation-making-your-app.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEQBQHg4eCp7ImA9WhVUFUk.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-5874101766289996240</id><published>2012-05-20T20:28:00.001+01:00</published><updated>2012-05-20T20:32:31.630+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-20T20:32:31.630+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="Navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Cocoon Navigation – Passing Arguments Between Pages</title><content type="html">Over the last couple of posts I have introduced the navigation framework that is included as part of the freely available &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; for developing Metro-style Windows 8 applications. I have &lt;a href="http://andyonwpf.blogspot.com/2012/04/navigation-in-cocoon-mvvm-for-metro.html"&gt;previously shown&lt;/a&gt; how to annotate pages with the PageExport and ViewModelExport attributes, and to navigate to these using the INavigationManager.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

Passing Arguments to ViewModels&lt;/h2&gt;
Whilst navigating between pages is a common pattern for modern applications, often you wish to pass some state during page navigation. As an example, imagine a photo browsing application. The “BrowsePhotos” page may show a number of images, which when clicked on navigates to a “ViewPhoto” page. In this case there needs to be some way to pass the image to display as an argument to the “ViewPhoto” page.&lt;br /&gt;
&lt;br /&gt;
This is made simple in the Cocoon navigation framework by a second overload of the INavigationManager.NavigateTo(…) method that takes both a page name and an argument to pass between the pages.&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; INavigationManager&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: blue;"&gt;string&lt;/span&gt; pageName);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: blue;"&gt;string&lt;/span&gt; pageName, &lt;span style="color: blue;"&gt;object&lt;/span&gt; arguments);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
The ‘arguments’ parameter can be of any type, however there are a number of restrictions that should be observed in practice,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;The type should be able to be serialized via a DataContractSerializer&lt;/li&gt;
&lt;br /&gt;
&lt;li&gt;The type should not rely on a reference to any particular object (for example if the value is from a shared cache it may be better to pass the key rather than the actual object to ensure that multiple versions are not created)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
In our photo application example we are caching the image details, so pass the photoID from the “BrowsePhotos” view model,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[ViewModelExport(&lt;span style="color: #006080;"&gt;"BrowsePhotos"&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; BrowsePhotosViewModel&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;readonly&lt;/span&gt; INavigationManager navigationManager;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Constructors ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    [ImportingConstructor]&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; BrowsePhotosViewModel(INavigationManager navigationManager)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.navigationManager = navigationManager;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Command Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ViewPhoto(Photo photo)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        navigationManager.NavigateTo(&lt;span style="color: #006080;"&gt;"ViewPhoto"&lt;/span&gt;, photo.PhotoId);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;

Activating Destination Pages&lt;/h2&gt;
The destination view model is able to accept parameters by implementing the IActivatable&amp;lt;TArguments, TState&amp;gt; interface where the type of the argument is designated by TArguments. The TState generic type will be discussed in a later blog post and if not required can be set as ‘string’.&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; IActivatable&amp;lt;TArguments, TState&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; Activate(TArguments arguments, TState state);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    TState SaveState();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
After creating the new view model the Cocoon framework will call the Activate(…) method passing in the argument passed from the call to INavigationManager.NavigatedTo(…). This method will only be called once and prior to display of the view.&lt;br /&gt;
&lt;br /&gt;
In our example photo browsing application the “ViewPhoto” view model will therefore be implemented as (Note that the unused SaveState() method simply returns ‘null’),&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[ViewModelExport(&lt;span style="color: #006080;"&gt;"ViewPhoto"&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; ViewPhotoViewModel : IActivatable&amp;lt;&lt;span style="color: blue;"&gt;string&lt;/span&gt;, &lt;span style="color: blue;"&gt;string&lt;/span&gt;&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** IActivatable Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; Activate(&lt;span style="color: blue;"&gt;string&lt;/span&gt; arguments, &lt;span style="color: blue;"&gt;string&lt;/span&gt; state)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Photo = GetPhoto(arguments);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; SaveState()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Private Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; Photo GetPhoto(&lt;span style="color: blue;"&gt;string&lt;/span&gt; photoId)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;

Summary&lt;/h2&gt;
&lt;br /&gt;
I have describe above how the Cocoon framework makes passing arguments between pages simple to implement. Over the next posts I will discuss some of the added value when using the Cocoon navigation framework, including how to make your application seem “always alive”.&lt;br /&gt;
&lt;br /&gt;
As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/H-obr4HhlbY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/5874101766289996240/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=5874101766289996240" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5874101766289996240?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5874101766289996240?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/H-obr4HhlbY/cocoon-navigation-passing-arguments.html" title="Cocoon Navigation – Passing Arguments Between Pages" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/05/cocoon-navigation-passing-arguments.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE4GRHg9cCp7ImA9WhVUEUw.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-7613832525027088155</id><published>2012-05-15T21:12:00.000+01:00</published><updated>2012-05-15T21:15:25.668+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-05-15T21:15:25.668+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="Navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Getting Started with Cocoon Navigation – The Cocoon Bootstrapper</title><content type="html">In &lt;a href="http://andyonwpf.blogspot.com/2012/04/navigation-in-cocoon-mvvm-for-metro.html"&gt;my last post&lt;/a&gt; I introduced the navigation framework that is included as part of the freely available &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; (open source on CodePlex). This framework is designed to make page based Metro-style applications easy to construct in managed languages on Windows 8.&lt;br /&gt;
&lt;br /&gt;
I &lt;a href="http://andyonwpf.blogspot.com/2012/04/navigation-in-cocoon-mvvm-for-metro.html"&gt;previously discussed&lt;/a&gt; how easy it was to implement the Model-View-ViewModel (MVVM) pattern with Cocoon by simply annotating your view and view models with the ‘PageExport’ and ‘ViewModel’ export attributes respectively. Any view model can then navigate to another page by calling the INavigationManager.NavigateTo(…) method.&lt;br /&gt;
&lt;br /&gt;
Since the Cocoon navigation framework is built on top of the Managed Extensibility Framework (MEF), the application is composed with the required dependencies as the user navigates through the application. MEF is a composition framework that is built into the .Net framework, that enables the construction of loosely-coupled, easily maintainable and testable applications to be composed automatically at run time. An introductory guide for those who are not familiar with MEF is available &lt;a href="http://www.codeproject.com/Articles/376033/From-Zero-to-Proficient-with-MEF"&gt;here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
What I have not covered previously however was how to navigate to the application’s first page when it is launched,&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;



Launching Navigation Using The Cocoon Bootstrapper&lt;/h2&gt;
To simplify the initialization of Cocoon based applications the framework includes the ‘CocoonBootstrapper’ class that can be used at startup. This manages the configuration of MEF for the most common scenarios, initialization of services and activation of the application.&lt;br /&gt;
&lt;br /&gt;
To use the Cocoon bootstrapper you must first create an application specific class derived from the abstract ‘CocoonBootstrapper’ as shown below. For basic applications this class can be left empty, although the base implementation provides a number of extensibility points to enable more advanced features.&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; AppBootstrapper : CocoonBootstrapper&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
The next stage is to edit your application’s ‘App.xaml.cs’ file. Much of the code included with the Visual Studio templates can be removed (since this is handled by Cocoon) and the newly created bootstrapper is initialized as part of the constructor.&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;sealed&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; App : Application&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; App()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.InitializeComponent();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// Create and initialize the application bootstrapper&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        AppBootstrapper bootstrapper = &lt;span style="color: blue;"&gt;new&lt;/span&gt; AppBootstrapper();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        bootstrapper.Initialize();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;h2&gt;



Defining the Application Home Page&lt;/h2&gt;
The final step is to define the view and (optionally) the view model that is to be shown when your application is launched. Whilst the home page name can be modified the default value defined by the ‘SpecialPageNames.HomePage’ constant is generally all that is required.&lt;br /&gt;
&lt;br /&gt;
Therefore the home page view is annotated as,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[PageExport(SpecialPageNames.HomePage)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;sealed&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; HomePage : LayoutAwarePage&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; HomePage()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.InitializeComponent();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
and the view model annotated as,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[ViewModelExport(SpecialPageNames.HomePage)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; HomeViewModel&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The Cocoon navigation framework will then automatically locate, create and wire-up the home page on application launch.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;



Summary&lt;/h2&gt;
Over the last two posts I have shown how easy the Cocoon navigation framework makes launching and navigating around Metro-style Windows 8 applications using the MVVM pattern. In the upcoming posts I will discuss some of the more advanced features you get when adopting Cocoon for navigation.&lt;br /&gt;
&lt;br /&gt;
As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/J-KBvqktkHQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/7613832525027088155/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=7613832525027088155" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7613832525027088155?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7613832525027088155?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/J-KBvqktkHQ/getting-started-with-cocoon-navigation.html" title="Getting Started with Cocoon Navigation – The Cocoon Bootstrapper" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/05/getting-started-with-cocoon-navigation.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEBQ3c_fCp7ImA9WhVWGE8.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-7503034385569545285</id><published>2012-04-30T22:47:00.001+01:00</published><updated>2012-04-30T22:50:52.944+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-30T22:50:52.944+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="Navigation" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Navigation in Cocoon – MVVM for Metro-style apps</title><content type="html">Over the next series of posts I’m going to introduce a new subsystem within the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; for Metro-style applications written in managed languages.&lt;br /&gt;
Modern rich client applications often consist of a number of interconnected pages or views. For example consider the Windows 8 “Store”. This has a home page that acts as a hub the links to a number of category pages, which in turn link to the individual application detail pages. The user navigates forward through the application flow by clicking images, buttons or links. They can also navigate backwards by using a back button that is placed in the top left hand corner of each page. In addition there are ‘special pages’ such as search, or even the settings panes available from the settings charm.&lt;br /&gt;
&lt;br /&gt;
There are a number of challenges for developers who wish to correctly implement such a navigation structure.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Navigation in Cocoon&lt;/h2&gt;
Although not limited to this, the Cocoon framework is designed to work great with the Model-View-ViewModel (MVVM) pattern that has become common when designing XAML based applications. One problem when using this pattern is that you need some way of associating a view with a view-model. Often this is done by navigating directly to a page, and using a “ViewModelLocator” to identify and wire up the respective view-model.&lt;br /&gt;
&lt;br /&gt;
In Cocoon a slightly different approach is used. Here, rather than navigating directly to a view, you navigate to a named page. Although the behaviour is extensible, by default Cocoon will use MEF (the built in composition framework included in .Net) to locate both the view and view-model associated with this page name, create and initialise instances of these and wire them together.&lt;br /&gt;
&lt;br /&gt;
You can export any XAML view (for example the pages created by any of the Visual Studio templates) by adding the ‘PageExport’ attribute to the code-behind file,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[PageExport(&lt;span style="color: #006080;"&gt;"BrowsePhotos"&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;sealed&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; BrowsePhotosPage : MyPhotoApp.Common.LayoutAwarePage&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; BrowsePhotosPage()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.InitializeComponent();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
And similarly you can export the view-model using the ‘ViewModelExport’ attribute,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[ViewModelExport(&lt;span style="color: #006080;"&gt;"BrowsePhotos"&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; BrowsePhotosViewModel&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;


The Navigation Manager&lt;/h2&gt;
In order to navigate between pages, Cocoon includes a navigation manager that can be accessed by importing the INavigationManager interface through MEF (simplified by the fact that all views and view models in Cocoon are themselves are composed by MEF).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; INavigationManager&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;bool&lt;/span&gt; CanGoBack { get; }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; GoBack();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: blue;"&gt;string&lt;/span&gt; pageName);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;void&lt;/span&gt; NavigateTo(&lt;span style="color: blue;"&gt;string&lt;/span&gt; pageName, &lt;span style="color: blue;"&gt;object&lt;/span&gt; arguments);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
The most interesting methods are the two overloads of ‘NavigateTo(…)’ that both take the page name to navigate to. The navigation manager will also keep track of the current navigation stack so that you can easily use the ‘CanGoBack’ property and ‘GoBack()’ method to traverse backwards through the previously visited pages.&lt;br /&gt;
&lt;br /&gt;
For example we could add methods to our BrowsePhotos view model as such,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;[ViewModelExport(&lt;span style="color: #006080;"&gt;"BrowsePhotos"&lt;/span&gt;)]&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; BrowsePhotosViewModel&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;readonly&lt;/span&gt; INavigationManager navigationManager;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Constructors ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    [ImportingConstructor]&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; BrowsePhotosViewModel(INavigationManager navigationManager)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.navigationManager = navigationManager;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Command Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; ViewPhoto()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        navigationManager.NavigateTo(&lt;span style="color: #006080;"&gt;"ViewPhoto"&lt;/span&gt;);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }    &lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;void&lt;/span&gt; NavigateBack()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        navigationManager.GoBack();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;


Summary&lt;/h2&gt;
&lt;br /&gt;
I have shown above how the Cocoon navigation framework allows you to easily construct a page based navigation structure for applications based upon the MVVM pattern. I have of course glossed over how you navigate to the first page of your application. I will discuss this further next time.&lt;br /&gt;
&lt;br /&gt;
As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/rFEhv6ghrE4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/7503034385569545285/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=7503034385569545285" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7503034385569545285?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7503034385569545285?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/rFEhv6ghrE4/navigation-in-cocoon-mvvm-for-metro.html" title="Navigation in Cocoon – MVVM for Metro-style apps" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/04/navigation-in-cocoon-mvvm-for-metro.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUEARHs_eSp7ImA9WhJWF08.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-720313116728382019</id><published>2012-04-22T20:31:00.001+01:00</published><updated>2012-08-23T13:07:25.541+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-08-23T13:07:25.541+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="MEF" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><title>Using MEF in Metro-style applications</title><content type="html">&lt;b&gt;Update 23 Aug 2012:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Since I originally wrote this post the standard .Net framework MEF implementation is no longer accessible from Windows 8 Windows Store applications. Instead MEF support is released out-of-band on NuGet as a specific &lt;a href="http://nuget.org/packages/microsoft.composition"&gt;"MEF for web and Windows Store apps"&lt;/a&gt; package. Once you have added this to your Windows 8 projects there is a slightly different programming model. For more information see the &lt;a href="http://mef.codeplex.com/documentation"&gt;Microsoft.Compostion documentation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In brief, you can set up composition with,&lt;br /&gt;
&lt;br /&gt;
&lt;pre&gt;var configuration = new ContainerConfiguration()
        .WithAssembly(typeof(App).GetTypeInfo().Assembly);&lt;/pre&gt;
&lt;pre&gt;var compositionHost = configuration.CreateContainer();
compositionHost.SatisfyImports(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;br /&gt;
&lt;u&gt;&lt;b&gt;Original post follows,&lt;/b&gt;&lt;b&gt; &lt;/b&gt;&lt;b&gt;&amp;nbsp;&lt;/b&gt;&lt;/u&gt; &lt;br /&gt;
&lt;br /&gt;
In a slight change from talking about the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt;, today I’m going to discuss how you may use MEF (the Managed Extensibility Framework) in Windows 8 Metro-style applications. Hopefully the reason for this deviation will become clear in my next post.&lt;br /&gt;
&lt;h2&gt;


What Is MEF?&lt;/h2&gt;
I’m not going to explain MEF in detail as this has been discussed many times before and is &lt;a href="http://msdn.microsoft.com/en-us/library/dd460648.aspx"&gt;described on MSDN&lt;/a&gt;. Succinctly, taken directly from the &lt;a href="http://mef.codeplex.com/"&gt;MEF CodePlex page&lt;/a&gt;,&lt;br /&gt;
&lt;blockquote&gt;
The &lt;b&gt;Managed Extensibility Framework&lt;/b&gt; (MEF) is a composition layer for .NET that improves the flexibility, maintainability and testability of large applications. MEF can be used for third-party plugin extensibility, or it can bring the benefits of a loosely-coupled plugin-like architecture to regular applications.&lt;/blockquote&gt;
For Windows 8 Metro-style app developers it is the loosely-coupled architecture that is of most interest (since third-party extensibility will not be applicable to application packages delivered through the Windows Store). This allows the individual components of your application to be designed, written and tested separately. The instantiation, lifetimes and connections between components is then managed by MEF at runtime.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Using MEF in Windows 8 Metro-Style Applications&lt;/h2&gt;
The good news is that MEF is included in the .Net base class libraries as part of the Metro-style application profile so is included in-the-box for all such applications. Unfortunately if you look at the documentation you will see references to ‘Assembly.GetExecutingAssembly()’ that is not available in the Metro-profile,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: green;"&gt;// Does not work in Metro-style applications&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;var catalog = &lt;span style="color: blue;"&gt;new&lt;/span&gt; AssemblyCatalog(System.Reflection.Assembly.GetExecutingAssembly());&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
All is not lost however, as you can access the main application assembly using,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: green;"&gt;// This does work in Metro-style applications!&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;var catalog = &lt;span style="color: blue;"&gt;new&lt;/span&gt; AssemblyCatalog(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(App).GetTypeInfo().Assembly);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Note that since&amp;nbsp;GetTypeInfo() is an extension method on 'Type'&amp;nbsp;you will have to add "using System.Reflection;" to the top of your source file. You can also reference other assemblies simply by picking a type contained in that assembly and replacing ‘App’ in the above snippet.&lt;br /&gt;
&lt;br /&gt;
Therefore a more complete snippet that would find and compose all imports in the current class is,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;var catalog = &lt;span style="color: blue;"&gt;new&lt;/span&gt; AssemblyCatalog(&lt;span style="color: blue;"&gt;typeof&lt;/span&gt;(App).GetTypeInfo().Assembly);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;var compositionService = catalog.CreateCompositionService();&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;compositionService.SatisfyImportsOnce(&lt;span style="color: blue;"&gt;this&lt;/span&gt;);&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Summary&lt;/h2&gt;
Hopefully this post will help anybody trying to integrate MEF with their Windows 8 Metro-style app development. Ultimately there is an ‘ApplicationCatalog’ that should allow you to generate a catalog from all assemblies within the app package however there is a &lt;a href="http://mef.codeplex.com/discussions/348566"&gt;known bug&lt;/a&gt; in the Consumer Preview bits.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/wOPLljaQJRQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/720313116728382019/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=720313116728382019" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/720313116728382019?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/720313116728382019?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/wOPLljaQJRQ/using-mef-in-metro-style-applications.html" title="Using MEF in Metro-style applications" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/04/using-mef-in-metro-style-applications.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUICQnoyeyp7ImA9WhVXFUw.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-2633942050107664404</id><published>2012-04-15T20:15:00.001+01:00</published><updated>2012-04-15T20:19:23.493+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-15T20:19:23.493+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="DataLists" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Using the Cocoon Data Framework</title><content type="html">Over the last series of posts I have discussed the Cocoon data framework. This aims to simplify the retrieval and display of data sets within Windows 8 Metro style applications. In particular it assists with pulling data from remote systems via typical page-based web APIs and displaying them as continuous lists.&lt;br /&gt;
The posts so far have covered,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://andyonwpf.blogspot.com/2012/01/bridging-data-dividean-introduction-to.html"&gt;Introductory post&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://andyonwpf.blogspot.com/2012/01/simpledatalistsource-consuming-data.html"&gt;SimpleDataListSource&lt;/a&gt; (for APIs that return all items from a single call)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://andyonwpf.blogspot.com/2012/02/pageddatalistsource-consuming-data-from.html"&gt;PagedDataListSource&lt;/a&gt; (for APIs that return data in a paged format)&lt;/li&gt;
&lt;li&gt;&lt;a href="http://andyonwpf.blogspot.com/2012/03/virtualizingdatalist-displaying-large.html"&gt;VirtualizingDataList&lt;/a&gt; (for data binding to display the data)&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;

The Cocoon Sample Application&lt;/h2&gt;
Included with the Cocoon source code (&lt;a href="http://cocoon.codeplex.com/"&gt;available from Codeplex&lt;/a&gt;) is a sample application that demonstrates there principles. This application is a simple Flickr viewer that displays the current list of “interesting” photos according to the Flickr API. Note that to compile this application you will need to register for a Flickr API key &lt;a href="http://www.flickr.com/services/apps/create/"&gt;here&lt;/a&gt; and place this in the ‘FLICKR_API_KEY’ constant within the ‘Data/FlickrApi.cs’ file.&lt;br /&gt;
In this application the FlickrApi class provides basic access to the Flickr API with a single method GetInterestingPhotos() [Note: This is for demonstration purposes only and is not designed to demonstrate good practice for creating a web API client]&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; Cocoon.Sample.Data&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;partial&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; FlickrApi&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// *** IMPORTANT : YOU MUST ENTER YOUR API KEY BELOW! ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;const&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; FLICKR_API_KEY = &lt;span style="color: #006080;"&gt;"ENTER YOUR FLICKR API KEY HERE"&lt;/span&gt;;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; async Task&amp;lt;FlickrPhotoPage&amp;gt; GetInterestingPhotos(&lt;span style="color: blue;"&gt;int&lt;/span&gt; page, &lt;span style="color: blue;"&gt;int&lt;/span&gt; perPage)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
You will notice that this retrieves data in a paged manner, passing in the page to return as an argument and returning a FlickrPhotoPage as a result. Note also that since this is an asynchronous method call the result is returned as a Task. In the UI however we have a single scrollable list of photos, so we will use the Cocoon data framework to link these together.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

Creating a New DataListSource&lt;/h2&gt;
It is recommended that when you are using the Cocoon data framework you expose the IDataListSource implementations though a data source singleton class. Since data list sources can perform some caching of the data this allows several pages of your application to use the same underlying source. In the sample application this it the FlickrDataSource class.&lt;br /&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; Cocoon.Sample.Data&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; FlickrDataSource&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; FlickrApi flickrApi = &lt;span style="color: blue;"&gt;new&lt;/span&gt; FlickrApi();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; IList&amp;lt;FlickrPhoto&amp;gt; interestingPhotos;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// *** Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; IList&amp;lt;FlickrPhoto&amp;gt; GetInterestingPhotos()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: green;"&gt;// Create a single instance of the interesting photos list&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: green;"&gt;// This can then be shared between multiple view models&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;if&lt;/span&gt; (interestingPhotos == &lt;span style="color: blue;"&gt;null&lt;/span&gt;)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;                InterestingPhotosDataListSource dataListSource = &lt;span style="color: blue;"&gt;new&lt;/span&gt; InterestingPhotosDataListSource(flickrApi);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;                interestingPhotos = (IList&amp;lt;FlickrPhoto&amp;gt;)&lt;span style="color: blue;"&gt;new&lt;/span&gt; VirtualizingDataList&amp;lt;FlickrPhoto&amp;gt;(dataListSource);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;return&lt;/span&gt; interestingPhotos;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Here we simply create an instance of our FlickrApi class along with a lazily generated InterestingPhotosDataListSource object. Whilst you can expose this to your rest of your application as is, here we also create a VirtualizingDataList&amp;lt;FlickrPhoto&amp;gt; passing the data list source into the constructor. Since this implements IList&amp;lt;FlickrPhoto&amp;gt; we can data bind to this in our UI.&lt;br /&gt;
The most interesting part of this is the InterestingPhotosDataListSource class – this is the class that you will need to write for each of the lists of data you wish to expose through the Cocoon data framework. As we have already discussed the Flickr API exposes the interesting photos feed as a series of pages, therefore we will derive from PagedDataListSource&amp;lt;FlickrPhoto&amp;gt;.&lt;br /&gt;
The three methods that we need to implement are FetchCountAsync, FetchPageSizeAsync and FetchPageAsync. Often however, as in this case, you will find that the number of items and page size are returned as part of the API call for returning the first page. Hence we only need to write an implementation of FetchPageAsync and use this to write the other two methods.&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;namespace&lt;/span&gt; Cocoon.Sample.Data&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; InterestingPhotosDataListSource : PagedDataListSource&amp;lt;FlickrPhoto&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;private&lt;/span&gt; FlickrApi flickrApi;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// *** Constructors ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;public&lt;/span&gt; InterestingPhotosDataListSource(FlickrApi flickrApi)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;this&lt;/span&gt;.flickrApi = flickrApi;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: green;"&gt;// *** Overriden Base Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;DataListPageResult&amp;lt;FlickrPhoto&amp;gt;&amp;gt; FetchCountAsync()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;return&lt;/span&gt; FetchPageAsync(1);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;DataListPageResult&amp;lt;FlickrPhoto&amp;gt;&amp;gt; FetchPageSizeAsync()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;return&lt;/span&gt; FetchPageAsync(1);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;protected&lt;/span&gt; async &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;DataListPageResult&amp;lt;FlickrPhoto&amp;gt;&amp;gt; FetchPageAsync(&lt;span style="color: blue;"&gt;int&lt;/span&gt; pageNumber)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            FlickrPhotoPage flickrPage = await flickrApi.GetInterestingPhotos(pageNumber, 20);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; DataListPageResult&amp;lt;FlickrPhoto&amp;gt;(flickrPage.Total, flickrPage.PerPage, flickrPage.Page, flickrPage.Photos);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
In the FetchPageAsync(…) method we directly call the FlickrAPI.GetInterestingPhotos method (using the new C# async support). The result is then returned as a DataListPageResut&amp;lt;T&amp;gt; with the total number of items, the number of items per page, the page number returned, and a list of the items within that page.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;

Data Binding to the Data List&lt;/h2&gt;
Since in this sample application we are using the MVVM pattern the user interface is split into two parts, the ‘InterestingPhotosPage.xaml’ and the ‘InterestingPhotosViewModel.cs’. In the view model we simple call FlickrDataSource.GetInterestingPhotos method that we wrote earlier and expose this IList&amp;lt;FlickrPhoto&amp;gt; as a property of the view model.&lt;br /&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;this&lt;/span&gt;.InterestingPhotos = flickrDataSource.GetInterestingPhotos();&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;br /&gt;
And in the XAML we bind to this property as you would any other collection,&lt;br /&gt;
&lt;br /&gt;&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;CollectionViewSource&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="itemsViewSource"&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: red;"&gt;Source&lt;/span&gt;&lt;span style="color: blue;"&gt;="{Binding InterestingPhotos}"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;

Summary&lt;/h2&gt;
I hope that I have shown above a brief insight into the power of the Cocoon data framework. We started by writing a simple “data list source” implementation describing how to access data from a paged web UI. The framework then allows you to easily expose this as a list that can be data bound to a UI, with support for virtualization and &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.isupportplaceholder.aspx"&gt;ISupportPlaceholder&lt;/a&gt; for free.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/83D6IM3MCNc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/2633942050107664404/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=2633942050107664404" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/2633942050107664404?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/2633942050107664404?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/83D6IM3MCNc/using-cocoon-data-framework.html" title="Using the Cocoon Data Framework" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>2</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/04/using-cocoon-data-framework.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUARHc5eSp7ImA9WhVQGEU.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-5501637378156882337</id><published>2012-03-20T21:03:00.000Z</published><updated>2012-04-08T12:24:05.921+01:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-04-08T12:24:05.921+01:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="DataLists" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>VirtualizingDataList – Displaying Large Datasets</title><content type="html">In the last few posts I have introduced a number of features from the data framework included as part of the open-source &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; for Windows 8 Metro-style apps. Following an &lt;a href="http://andyonwpf.blogspot.com/2012/01/bridging-data-dividean-introduction-to.html"&gt;introduction to the framework&lt;/a&gt; I described the &lt;a href="http://andyonwpf.blogspot.com/2012/01/simpledatalistsource-consuming-data.html"&gt;SimpleDataListSource&lt;/a&gt; and &lt;a href="http://andyonwpf.blogspot.com/2012/02/pageddatalistsource-consuming-data-from.html"&gt;PagedDataListSource&lt;/a&gt;.&lt;br /&gt;
To recap, the IDataListSource implementations provide a simple way of accessing data from web APIs. These have been designed to reflect the typical structure of such APIs, generally resulting from a series of stateless HTTP requests to retrieve the data, often a page at a time.&lt;br /&gt;
In response to data provided from an IDataListSource, the DataList implementations are designed to request and display the information to the user. The aim here is to provide the user experience expected for a client application, with large scrolling lists of items and suitable support for background on-demand data retrieval.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Introducing The VirtualizingDataList&lt;/h2&gt;
The first DataList implementation provided in the Cocoon data framework is the VirtualizingDataList&amp;lt;T&amp;gt; class. This can be used for situations where a large scrolling list only displays a small subset of the data at any one time. Only the data in view will be retrieved, with more data being fetched on-demand as the user scrolls through this list. In addition it supports the WinRT &lt;a href="http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.data.isupportplaceholder"&gt;ISupportPlaceholder interface&lt;/a&gt; to indicate to the displaying UI to display a placeholder element whilst data is being retrieved in the background. This builds on top of Cocoon’s VirtualizingVector class so more information on data virtualization and placeholder support can be found in &lt;a href="http://andyonwpf.blogspot.com/2011/12/data-virtualization-in-metro-style-apps.html"&gt;the associated post&lt;/a&gt;.&lt;br /&gt;
To use a VirtualizingDataList&amp;lt;T&amp;gt; you simply create a new instance, passing the IDataListSource via its constructor. It can then be bound to any of the many controls for displaying lists of information, most commonly the GridView and ListView controls.&lt;br /&gt;
If you are following the MVVM presentation pattern then you will expose the data list via a view model,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; MyViewModel&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; IList&amp;lt;Person&amp;gt; employees;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Constructors ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; MyViewModel()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        IDataListSource&amp;lt;Person&amp;gt; source = &lt;span style="color: blue;"&gt;new&lt;/span&gt; EmployeesDataListSource();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        employees = &lt;span style="color: blue;"&gt;new&lt;/span&gt; VirtualizingDataList&amp;lt;Person&amp;gt;(source);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Properties ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; IList&amp;lt;Person&amp;gt; Employees&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        get&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;            &lt;span style="color: blue;"&gt;return&lt;/span&gt; employees;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Then in your XAML you can define a CollectionViewSource that binds to the data list, and connect that to your items control,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;CollectionViewSource&lt;/span&gt; &lt;span style="color: red;"&gt;x:Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="itemsViewSource"&lt;/span&gt; &lt;span style="color: red;"&gt;Source&lt;/span&gt;&lt;span style="color: blue;"&gt;="{Binding Employees}"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;UserControl.Resources&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;...&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;GridView&lt;/span&gt; &lt;span style="color: red;"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: blue;"&gt;="{Binding Source={StaticResource itemsViewSource}}"&lt;/span&gt; ... &lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
In fact, this is exactly what the Visual Studio 11 Metro-style XAML templates will produce for you.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Summary&lt;/h2&gt;
In the above discussing I have shown how easy it is to consume any IDataListSource and display it to the user through the fluid scrollable user experience expected of modern applications. When I &lt;a href="http://andyonwpf.blogspot.com/2012/01/bridging-data-dividean-introduction-to.html"&gt;introduced the Cocoon data framework&lt;/a&gt; I discussed “bridging the data divide” between the stateless HTTP calls of web APIs and the continuous scrollable lists displayed to the user. By coding the former as IDataListSource implementations, and the latter as DataLists, Cocoon provides the bridge to span these two worlds.&lt;br /&gt;
&lt;br /&gt;
As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;


Notes&lt;/h2&gt;
Please note that due to a known issue with the Visual Studio templates in the Consumer Preview (&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/17385f7d-aadc-4edc-bbff-8738a2f0c917"&gt;see this forum post&lt;/a&gt;) they disable virtualization support for the GridView. Therefore although the VirtualizingVector and VirtualizingDataList classes will still work, they unfortunately fetch all items in the collection rather than on demand. To re-enable the virtualization support you can remove the ScrollViewer that surrounds the GridView, however this will clip elements a little strangely. Hopefully this will be resolved in the final release of Visual Studio, although I am working on a temporary workaround.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/ndK3-mq1REM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/5501637378156882337/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=5501637378156882337" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5501637378156882337?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/5501637378156882337?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/ndK3-mq1REM/virtualizingdatalist-displaying-large.html" title="VirtualizingDataList – Displaying Large Datasets" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/03/virtualizingdatalist-displaying-large.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMGSX86fip7ImA9WhVREko.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-7513495894735180308</id><published>2012-03-18T20:29:00.001Z</published><updated>2012-03-20T21:03:48.116Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-03-20T21:03:48.116Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Update: Cocoon for Windows Consumer Preview</title><content type="html">Following the release of the Windows 8 Consumer preview I would like to announce that the Cocoon framework for Windows 8 Metro-style applications has been updated to support the new bits. As usual the full source code is available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;br /&gt;
&lt;br /&gt;
The&amp;nbsp;changes include,&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;Code and project system migrated to the Visual Studio 11 Consumer Preview&lt;/li&gt;
&lt;li&gt;Virtualization support converted to use the new ISupportPlaceholder interface rather than IVirtualizingVector&lt;/li&gt;
&lt;li&gt;The VirtualizingVector class is now VirtualizingVector&amp;lt;T&amp;gt; for type-safe&amp;nbsp;access&lt;/li&gt;
&lt;li&gt;Improvements to the internal resource management&lt;/li&gt;
&lt;li&gt;General tidying up of the codebase&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;/ul&gt;
Please note that due to a known issue with the Visual Studio templates in the Consumer Preview&amp;nbsp;(&lt;a href="http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/17385f7d-aadc-4edc-bbff-8738a2f0c917"&gt;see this forum post&lt;/a&gt;) they disable virtualization support for the&amp;nbsp;GridView. Therefore although&amp;nbsp;the VirtualizingVector and VirtualizingDataList classes will still work, they unfortunately&amp;nbsp;fetch all items in the collection rather than on demand. To re-enable the&amp;nbsp;virtualization support you can remove the ScrollViewer that surrounds the GridView, however this will clip elements a little strangely. Hopefully this will be resolved in the final release of Visual Studio, although I am working on a temporary workaround.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/4vGjVZPdfwc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/7513495894735180308/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=7513495894735180308" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7513495894735180308?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7513495894735180308?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/4vGjVZPdfwc/update-cocoon-for-windows-consumer.html" title="Update: Cocoon for Windows Consumer Preview" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/03/update-cocoon-for-windows-consumer.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YNQHYyeCp7ImA9WhRbFUs.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-7639963858564540723</id><published>2012-02-06T21:44:00.001Z</published><updated>2012-02-06T21:53:11.890Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-06T21:53:11.890Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="DataLists" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>PagedDataListSource – Consuming Data From Common Web APIs</title><content type="html">This is my third post in a series discussing the data framework that is included as part of the open-source &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt;. Previously I have &lt;a href="http://andyonwpf.blogspot.com/2012/01/bridging-data-dividean-introduction-to.html"&gt;introduced the framework&lt;/a&gt;, and detailed the &lt;a href="http://andyonwpf.blogspot.com/2012/01/simpledatalistsource-consuming-data.html"&gt;SimpleDataListSource base implementation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
In this post I will describe the more advanced PagedDataListSource base implementation included as part of the framework. This is designed to allow simple integration of data that is retrieved from web APIs as a series of pages. This is a common approach to enable access to large data sets in an efficient manner. In general there will be some way to retrieve the number of items in the data set, and a way to retrieve a single ‘page’ of data (often these can be combined in a single API call).&lt;br /&gt;
&lt;br /&gt;
Consider for example a hypothetical web call,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;http://www.example.com/api/getEmployees?page=1&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
This might return the following XML response,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;PersonResult&lt;/span&gt; &lt;span style="color: red;"&gt;TotalCount&lt;/span&gt;&lt;span style="color: blue;"&gt;="450"&lt;/span&gt; &lt;span style="color: red;"&gt;Page&lt;/span&gt;&lt;span style="color: blue;"&gt;="1"&lt;/span&gt; &lt;span style="color: red;"&gt;PageSize&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Person&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Bob"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Person&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Dave"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Person&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Amy"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;PersonResult&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
We can immediately see that there are a total of 450 employees, however the API returns only the first 50 entries. To retrieve subsequent employees you make the same call with the relevant ‘page’ query parameter.&lt;br /&gt;
&lt;br /&gt;
From the point of view of a modern Windows 8 Metro style application, the user does not want to see separate pages of data. Instead they expect a continuous scrolling grid of items, with subsequent data retrieved on demand as it is required to be displayed. It is this mismatch between the paging web API and the desired UI that the PagedDataListSource and the Cocoon data framework sets out to address.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;








Implementing A PagedDataListSource&lt;/h2&gt;
The PagedDataListSource&amp;lt;T&amp;gt; class in marked as abstract so you must derive a domain specific custom class for the type of data that you wish to retrieve. There are then three methods that you should override,&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;FetchCountAsync – This should retrieve the number of items in the data set&lt;/li&gt;
&lt;br /&gt;
&lt;li&gt;FetchPageSizeAsync – This should return the number of items per page&lt;/li&gt;
&lt;br /&gt;
&lt;li&gt;FetchPageAsync – This should return the items for a specified page&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Note that each of these returns a Task&amp;lt;DataListPageResult&amp;lt;T&amp;gt;&amp;gt; as their response. DataListPageResult&amp;lt;T&amp;gt; is defined as,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;struct&lt;/span&gt; DataListPageResult&amp;lt;T&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Constructors ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; DataListPageResult(&lt;span style="color: blue;"&gt;int&lt;/span&gt;? totalItemCount, &lt;span style="color: blue;"&gt;int&lt;/span&gt;? itemsPerPage,&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;                              &lt;span style="color: blue;"&gt;int&lt;/span&gt;? pageNumber, IList&amp;lt;T&amp;gt; page)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        : &lt;span style="color: blue;"&gt;this&lt;/span&gt;()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.TotalItemCount = totalItemCount;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.ItemsPerPage = itemsPerPage;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.PageNumber = pageNumber;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.Page = page;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Properties ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;? TotalItemCount { get; &lt;span style="color: blue;"&gt;private&lt;/span&gt; set; }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;? ItemsPerPage { get; &lt;span style="color: blue;"&gt;private&lt;/span&gt; set;}&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;int&lt;/span&gt;? PageNumber { get; &lt;span style="color: blue;"&gt;private&lt;/span&gt; set; }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; IList&amp;lt;T&amp;gt; Page { get; &lt;span style="color: blue;"&gt;private&lt;/span&gt; set; }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
This contains all the data that could be returned from any of the above methods. Whilst the requested information must always be present (e.g. a call to FetchCountAsync() must always return a ‘TotalItemCount’) any of the other values may be ‘null’ if they are not known.&lt;br /&gt;
&lt;br /&gt;
The reason for this approach is that in many cases several of these items are returned from a single web API call – for example in the ‘getEmployees’ example above an initial call to GetFetchAsync() will not only return the number of items, but also the page size and the contents of the first page. Hence the implementation can often write FetchCountAsync() and FetchPageSizeAsync() as a simple call to FetchPageAsync(…).&lt;br /&gt;
&lt;br /&gt;
So for our hypothetical ‘getEmployees’ web call we could write,&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; EmployeesDataListSource : PagedDataListSource&amp;lt;Person&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Overriden Base Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;DataListPageResult&amp;lt;Person&amp;gt;&amp;gt;
                           FetchCountAsync()&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;return&lt;/span&gt; FetchPageAsync(1);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;DataListPageResult&amp;lt;Person&amp;gt;&amp;gt;
                           FetchPageSizeAsync()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;return&lt;/span&gt; FetchPageAsync(1);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; async &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;DataListPageResult&amp;lt;Person&amp;gt;&amp;gt;
                                 FetchPageAsync(&lt;span style="color: blue;"&gt;int&lt;/span&gt; pageNumber)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        PersonResult result = await ExampleEmployeesApi.
                                         GetEmployees(pageNumber);&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;return&lt;/span&gt; &lt;span style="color: blue;"&gt;new&lt;/span&gt; DataListPageResult&amp;lt;FlickrPhoto&amp;gt;
                      (result.TotalCount, result.PageSize,
                       result.Page, result.Items);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
The Cocoon framework will then ensure that the correct pages are retrieved as required and that each web API call is only made once, with the results cached for future use.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;








Summary&lt;/h2&gt;
Here I have discussed the PagedDataListSource&amp;lt;T&amp;gt; implementation of the Cocoon data framework. As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link).&lt;br /&gt;
&lt;br /&gt;
Next time I will show how you link these IDataListSource implementations with a DataList that can then be bound to your Windows 8 Metro style app’s UI. Following this I will show an end-to-end sample of how to the data framework to access a real web API and display it to the end user (Note: If you are really eager, the sample application is available from the latest code drop on the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt;).&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/r-yAyK3SgxU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/7639963858564540723/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=7639963858564540723" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7639963858564540723?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/7639963858564540723?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/r-yAyK3SgxU/pageddatalistsource-consuming-data-from.html" title="PagedDataListSource – Consuming Data From Common Web APIs" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/02/pageddatalistsource-consuming-data-from.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4HRHsyeCp7ImA9WhRbEEk.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-6253082056333000099</id><published>2012-01-31T22:06:00.001Z</published><updated>2012-01-31T22:12:15.590Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-31T22:12:15.590Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="DataLists" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>SimpleDataListSource – Consuming Data From Simple Services</title><content type="html">In my &lt;a href="http://andyonwpf.blogspot.com/2012/01/bridging-data-dividean-introduction-to.html"&gt;last post&lt;/a&gt; I introduced the data framework exposed as part of the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework project&lt;/a&gt;. Whilst the same principles could be applied to any presentation layer, this framework is designed from the ground up to work great with Windows 8 Metro applications written in managed .Net languages. This includes support for several of the advanced features of WinRT based UIs, such as data virtualization (which I discussed in &lt;a href="http://andyonwpf.blogspot.com/2011/12/data-virtualization-in-metro-style-apps.html"&gt;this post&lt;/a&gt;).&lt;br /&gt;
&lt;br /&gt;
As I discussed, Cocoon splits the passing of data from a data source into the UI with two parts. The DataListSource (represented by the IDataListSource&amp;lt;T&amp;gt; interface) describes how the data is retrieved and maps well onto the typical web service API calls to do so. At the other end of the pipeline is the DataList whose responsibility it is to determine when to retrieve the data and to present it in a format that is easily bound to the UI.&lt;br /&gt;
&lt;br /&gt;
Whilst this system is designed to be easily extensible, there are a number of typical use-cases that are provided out of the box with the Cocoon framework. In this post I will describe the SimpleDataListSource.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;




The SimpleDataListSource Class&lt;/h2&gt;
The SimpleDataListSource&amp;lt;T&amp;gt;, as its name suggests, is an implementation of the IDataListSource&amp;lt;T&amp;gt; interface for use with simple web APIs that return all items in a list with a single API call.&lt;br /&gt;
&lt;br /&gt;
As an example consider the Flickr API method &lt;a href="http://www.flickr.com/services/api/flickr.photos.people.getList.html"&gt;flickr.photos.people.getList&lt;/a&gt; that returns all the people that are tagged in a given photo. Since the number of people is likely to be relatively small the API simply takes a photo ID and returns all the people in one go, and is an ideal candidate for the SimpleDataListSource&amp;lt;T&amp;gt;. This is in contrast to a method such as &lt;a href="http://www.flickr.com/services/api/flickr.interestingness.getList.html"&gt;flickr.interestingness.getList&lt;/a&gt; that returns all the interesting photos for the current day. In this case they may be many hundred items so the Flickr API splits these into several pages that are returned one at a time.&lt;br /&gt;
&lt;br /&gt;
In code form we could consider this as,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; FlickrApi&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; Task&amp;lt;IList&amp;lt;PeopleTag&amp;gt;&amp;gt; GetPeopleInPhoto(&lt;span style="color: blue;"&gt;string&lt;/span&gt; photoId)&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        ...&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; Task&amp;lt;IList&amp;lt;Photo&amp;gt;&amp;gt; GetInterestingPhotos(&lt;span style="color: blue;"&gt;int&lt;/span&gt; page)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        ...&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h2&gt;




Implementing A Simple Data Source&lt;/h2&gt;
Since SimpleDataSource&amp;lt;T&amp;gt; is an abstract class you must first derive a custom class for a specific data type. The only method you then are required to implement is the FetchItemsAsync() method that will initiate the call to the web API to retrieve all the items.&lt;br /&gt;
&lt;br /&gt;
For our Flickr photo tagging example,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;class&lt;/span&gt; TaggedPeopleDataListSource : SimpleDataSource&amp;lt;PeopleTag&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Fields ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; FlickrApi flickrApi;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;private&lt;/span&gt; &lt;span style="color: blue;"&gt;string&lt;/span&gt; photoId;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Constructors ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;public&lt;/span&gt; TaggedPeopleDataListSource(&lt;span style="color: blue;"&gt;string&lt;/span&gt; photoId, FlickrApi flickrApi)&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.flickrApi = flickrApi;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;this&lt;/span&gt;.photoId = photoId;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: green;"&gt;// *** Overriden Methods ***&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&amp;nbsp;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;protected&lt;/span&gt; &lt;span style="color: blue;"&gt;override&lt;/span&gt; Task&amp;lt;IList&amp;lt;PeopleTag&amp;gt;&amp;gt; FetchItemsAsync()&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    {&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;        &lt;span style="color: blue;"&gt;return&lt;/span&gt; flickrApi.GetPeopleInPhoto(&lt;span style="color: blue;"&gt;string&lt;/span&gt; photoId);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    }&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Here we firstly derive from ‘SimpleDataListSource&amp;lt;PeopleTag&amp;gt;’ (since every item in the list is of type ‘PeopleTag’). In the constructor we take the photo ID to retrieve the tagged people, and a reference to the ‘FlickrApi’ implementation. In the FetchItemsAsync() method we simply call the API method and return the result.&lt;br /&gt;
&lt;br /&gt;
The underlying SimpleDataListSource&amp;lt;T&amp;gt; implementation will ensure that the web API is only called once, and will cache the results in memory for future use.&lt;br /&gt;
&lt;br /&gt;
As usual the code is freely available for download from the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon CodePlex site&lt;/a&gt; (to get the latest version go to the “Source Code” tab, select the first change set and use the “Download” link). &lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;




Next Time&lt;/h2&gt;
Whilst simple scenarios such as those supported by the SimpleDataListSource are relatively basic to implement without the support provided by the Cocoon framework, many web APIs return paged results that are much more difficult to consume. For a fast and responsive UI these should be retrieved asynchronously and on demand as the user scrolls through a long list of items.&lt;br /&gt;
&lt;br /&gt;
Next time I will introduce the PagedDataListSource that allows you to support this with minimal code. After that I will introduce the final piece in the puzzle – the DataList that can be connected to any of these DataListSources for binding to the UI. Finally I will describe a simple end-to-end example of how to use the data framework to bind to a real web service.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/E0UDzmw3Rgg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/6253082056333000099/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=6253082056333000099" title="4 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/6253082056333000099?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/6253082056333000099?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/E0UDzmw3Rgg/simpledatalistsource-consuming-data.html" title="SimpleDataListSource – Consuming Data From Simple Services" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><thr:total>4</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/01/simpledatalistsource-consuming-data.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEcESX4zeip7ImA9WhRVGE4.&quot;"><id>tag:blogger.com,1999:blog-8838794302949839825.post-2913475193406692329</id><published>2012-01-17T21:33:00.000Z</published><updated>2012-01-17T21:33:28.082Z</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-17T21:33:28.082Z</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="MVVM" /><category scheme="http://www.blogger.com/atom/ns#" term="Metro" /><category scheme="http://www.blogger.com/atom/ns#" term="DataLists" /><category scheme="http://www.blogger.com/atom/ns#" term="Windows 8" /><category scheme="http://www.blogger.com/atom/ns#" term="Cocoon" /><title>Bridging the Data Divide–An Introduction to Cocoon Data Lists</title><content type="html">When I &lt;a href="http://andyonwpf.blogspot.com/2011/11/cocoon-new-framework-for-windows-8.html"&gt;first introduced the Cocoon framework&lt;/a&gt; one of the targets was to improve the ease at which data retrieval APIs (primarily web APIs) could be integrated into modern desktop applications. In this post I will introduce two concepts, the “data list” and the “data list source”, that are used in the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; to simplify this process when writing Windows 8 Metro-style applications, in particular those implementing the MVVM design pattern.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
The Data Divide&lt;/h2&gt;
Let us first consider a typical web API that will return a list of information in response to a web request from a desktop application. In many cases there may be a large number of items in the list, so the API will split the results into several “pages”. For example, the hypothetical web call,&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; Task&amp;lt;PersonResult&amp;gt; GetEmployeesAsync(&lt;span style="color: blue;"&gt;int&lt;/span&gt; pageNumber) {...}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Might return the resulting data for pageNumber=1,&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;br /&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;PersonResult&lt;/span&gt; &lt;span style="color: red;"&gt;TotalCount&lt;/span&gt;&lt;span style="color: blue;"&gt;="450"&lt;/span&gt; &lt;span style="color: red;"&gt;Page&lt;/span&gt;&lt;span style="color: blue;"&gt;="1"&lt;/span&gt; &lt;span style="color: red;"&gt;PageSize&lt;/span&gt;&lt;span style="color: blue;"&gt;="50"&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Person&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Bob"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Person&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Dave"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    &lt;span style="color: blue;"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: maroon;"&gt;Person&lt;/span&gt; &lt;span style="color: red;"&gt;Name&lt;/span&gt;&lt;span style="color: blue;"&gt;="Amy"&lt;/span&gt;&lt;span style="color: blue;"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    ...&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: maroon;"&gt;PersonResult&lt;/span&gt;&lt;span style="color: blue;"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
Here, whilst there are a total of 450 items in the data set, only the first 50 are returned. If you then require any further items then additional calls must be made for the second, third, etc. pages as required.&lt;br /&gt;
&lt;br /&gt;
In contrast let us consider a modern Windows 8 Metro-style UI. Here the user generally expects to see a single list of all items that can be scrolled through as desired. For performance reasons this list should take advantage of data virtualisation to retrieve data on demand, filling in the UI smoothly as the results are retrieved (see &lt;a href="http://andyonwpf.blogspot.com/2011/12/data-virtualization-in-metro-style-apps.html"&gt;my last post on VirtualizingVector&lt;/a&gt; for more information).&lt;br /&gt;
&lt;br /&gt;
It is this “data divide” between the state-less paged result sets of web APIs and the fluid continuous lists of desktop applications that often require much code to implement correctly. This is the problem that “data lists” and “data list sources” in the Cocoon framework are desired to solve.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
“Data Lists” and “Data List Sources”&lt;/h2&gt;
&lt;br /&gt;
The approach taken by the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; is to separate the two concerns of the web API calls (or any other data access call) and the resulting lists to display in the UI into separate components. These can then be developed separately using their own conventions, with the Cocoon framework bridging the divide.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-ka6ijr-Y0v8/TxXoLdoOlnI/AAAAAAAAAC8/Y8j_M8xj99Y/s1600/Data+List+Scheme.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="55" src="http://3.bp.blogspot.com/-ka6ijr-Y0v8/TxXoLdoOlnI/AAAAAAAAAC8/Y8j_M8xj99Y/s400/Data+List+Scheme.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
In this model a web API call (or calls) that return information on a list of information is represented as part of a “data list source”. This understands how to query the source API to retrieve the list of data as required. In addition it is your application’s own representation of what it knows about the list of data – the length of the data set, and any items that have already been downloaded. This can be reused amongst different parts of your application and in some ways acts as a local cache of the data. Multiple data list sources will be available, for simple cases where all data is returned at once and for data that is returned by pages, as well as the option for custom implementations.&lt;br /&gt;
&lt;br /&gt;
At the other end of the chain is the “data list”. This is the IList&amp;lt;T&amp;gt; implementation that is bound to the UI, either via the code behind or through a view model. Multiple data lists can be attached to the same data list source so that the application’s view of the data is consistent. Different data list implementations can determine how the data is retrieved for display; for example,&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;StaticDataList – This will retrieve all the information before display to the user &lt;/li&gt;
&lt;li&gt;VirtualizingDataList – This will use data virtualization to only retrieve the data items that are currently visible to the user &lt;/li&gt;
&lt;li&gt;IncrementalLoadingDataList – This will initially show a fixed number of items, but allow the user to expand the list if they wish to see more items &lt;/li&gt;
&lt;li&gt;DynamicDataList – This will start with an empty list, with items being added as they are retrieved from the data list source&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Between the data list and the data list source are a number of optional processing steps. For example these could constrain the list to only the first 50 items for preview, they could filter the items based on a search term, or could group the items to display as part of a grouped grid view.&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
The IDataListSource Interface&lt;/h2&gt;
All of the above is orchestrated by the Cocoon.Data.IDataListSource&amp;lt;T&amp;gt; interface.&lt;br /&gt;
&lt;br /&gt;
&lt;div id="codeSnippetWrapper"&gt;
&lt;div id="codeSnippet" style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;&lt;span style="color: blue;"&gt;public&lt;/span&gt; &lt;span style="color: blue;"&gt;interface&lt;/span&gt; IDataListSource&amp;lt;T&amp;gt;&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;{&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    Task&amp;lt;&lt;span style="color: blue;"&gt;int&lt;/span&gt;&amp;gt; GetCountAsync();&lt;/pre&gt;
&lt;pre style="background-color: #f4f4f4; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;    Task&amp;lt;T&amp;gt; GetItemAsync(&lt;span style="color: blue;"&gt;int&lt;/span&gt; index);&lt;/pre&gt;
&lt;pre style="background-color: white; color: black; direction: ltr; font-family: &amp;quot;Courier New&amp;quot;, courier, monospace; font-size: 8pt; line-height: 12pt; margin: 0em; overflow: visible; padding: 0px; text-align: left; width: 100%;"&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
You can think of this as an asynchronous version of IList&amp;lt;T&amp;gt;, albeit a minimal version. There are two methods:&lt;br /&gt;
&lt;ul&gt;&lt;br /&gt;
&lt;li&gt;GetCountAsync() – Returns a task that results in the number of items in the list.&lt;/li&gt;
&lt;br /&gt;
&lt;li&gt;GetItemAsync(int index) – Returns a task that results in the item at the specified index.&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
Note that the GetItemAsync(…) method should throw an exception if ‘index’ is less than zero, however if ‘index’ is greater than the last item it should return default(T) (for reference types this will be null).&lt;br /&gt;
&lt;br /&gt;
&lt;h2&gt;
Summary&lt;/h2&gt;
To summarize, the &lt;a href="http://cocoon.codeplex.com/"&gt;Cocoon framework&lt;/a&gt; supplies an infrastructure designed to bridge the gap between state-less web APIs and modern fluid Windows 8 Metro style applications. Over the next few blog posts (and associated code drops) I will provide a number of generic implementations of data lists and data list sources to make consuming lists of data from the web quick and easy.&lt;img src="http://feeds.feedburner.com/~r/AndyOnWpf/~4/YHK2XGMWPCM" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://andyonwpf.blogspot.com/feeds/2913475193406692329/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=8838794302949839825&amp;postID=2913475193406692329" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/2913475193406692329?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8838794302949839825/posts/default/2913475193406692329?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/AndyOnWpf/~3/YHK2XGMWPCM/bridging-data-dividean-introduction-to.html" title="Bridging the Data Divide–An Introduction to Cocoon Data Lists" /><author><name>Andrew Wilkinson</name><uri>https://plus.google.com/100725352564501502522</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="16" height="16" src="http://img2.blogblog.com/img/b16-rounded.gif" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-ka6ijr-Y0v8/TxXoLdoOlnI/AAAAAAAAAC8/Y8j_M8xj99Y/s72-c/Data+List+Scheme.png" height="72" width="72" /><thr:total>0</thr:total><gd:extendedProperty name="commentSource" value="1" /><gd:extendedProperty name="commentModerationMode" value="FILTERED_POSTMOD" /><feedburner:origLink>http://andyonwpf.blogspot.com/2012/01/bridging-data-dividean-introduction-to.html</feedburner:origLink></entry></feed>
