<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Erwin van der Valk's blog: Practicing patterns : Silverlight</title><link>http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx</link><description>Tags: Silverlight</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>writing applications that target both wpf and silverlight with a single codebase</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/09/03/writing-applications-that-target-both-wpf-and-silverlight-with-a-single-codebase.aspx</link><pubDate>Thu, 03 Sep 2009 23:09:50 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9891066</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9891066.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9891066</wfw:commentRss><description>&lt;p&gt;A while back, I wrote an MSDN article on writing multi-targeted programs with Prism.&lt;/p&gt;  &lt;p&gt;&lt;a title="http://msdn.microsoft.com/en-us/magazine/ee321573.aspx" href="http://msdn.microsoft.com/en-us/magazine/ee321573.aspx"&gt;http://msdn.microsoft.com/en-us/magazine/ee321573.aspx&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Hope you like it!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9891066" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item><item><title>prism v2 – drop 10 (composite application guidance)</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/01/30/prism-v2-drop-10-composite-application-guidance.aspx</link><pubDate>Sat, 31 Jan 2009 02:41:41 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9385502</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9385502.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9385502</wfw:commentRss><description>&lt;p&gt;Today, we have released what’s likely going to be the last drop of Prism before the final release. You can get the release from:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=22566" href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=22566"&gt;http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=22566&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;During this iteration, we have mostly worked on documentation, implementing a new UI for the Stock Trader Reference Implementation and fixing some last important bugs. &lt;/p&gt;  &lt;p&gt;The most important changes are:&lt;/p&gt;  &lt;li&gt;Removed .Silverlight and .Desktop extensions from the Assembly names, both in the Library and in all the Quickstarts. &lt;/li&gt;  &lt;li&gt;Renamed RegionExtensions class to RegionContext and RegionExtensions.GetRegionContext() method to RegionContext.GetObservableContext() &lt;/li&gt;  &lt;li&gt;Moved RegionExtensions.GetObservableRegion() method from RegionExtensions class to RegionManager class. &lt;/li&gt;  &lt;li&gt;Integrated new UI design for Stock Trader Reference Implementation. &lt;/li&gt;  &lt;li&gt;Many updates to Documentation &lt;/li&gt;  &lt;li&gt;Included API CHM file &lt;/li&gt;  &lt;li&gt;Added shortcut .Bat files to make it easier to open the solutions. &lt;/li&gt;  &lt;li&gt;Bug fixes &lt;/li&gt;  &lt;li&gt;Added missing XML comments to the code of the Composite Application Library.&lt;/li&gt;  &lt;h1&gt;&amp;#160;&lt;/h1&gt;  &lt;h1&gt;New UI for Stock Trader Reference Implementation&lt;/h1&gt;  &lt;p&gt;We felt that the original UI of the Stocktrader RI didn’t give a good impression of the capabilities of WPF and Silverlight. Most of the things we were showing before were also possible with Windows Forms. So for this release, we’ve decided to hire a graphical design company to give our RI a complete makeover, complete with some cool animations. &lt;/p&gt;  &lt;table border="0" cellspacing="0" cellpadding="2" width="400"&gt;&lt;tbody&gt;     &lt;tr&gt;       &lt;td valign="top" width="200"&gt;&lt;strong&gt;Before:&lt;/strong&gt;&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_2.png"&gt;           &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_thumb.png" width="463" height="313" /&gt;&lt;/a&gt;&lt;/td&gt;        &lt;td valign="top" width="200"&gt;After:&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_6.png"&gt;           &lt;br /&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/prismv2drop10compositeapplicationguidanc_DCB4/image_thumb_2.png" width="410" height="313" /&gt;&lt;/a&gt;&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt; Looks a lot better huh?&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9385502" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item><item><title>prism v2 – drop 9 (composite application guidance for wpf and silverlight)</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2009/01/19/prism-v2-drop-9-composite-application-guidance-for-wpf-and-silverlight.aspx</link><pubDate>Mon, 19 Jan 2009 22:32:29 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9340600</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9340600.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9340600</wfw:commentRss><description>&lt;p&gt;It’s been a while since my last post. Not that the Prism team has been sitting idle though. &lt;/p&gt;  &lt;p&gt;Last Friday, we’ve released drop 9 of Prism. As we are approaching the end of the Prism v2 project, there are a lot less API changes, as we are mostly focussing on finishing the docs and resolving bugs. We have also spent some time trying to build different application styles (for example, an outlook style app, or a master-detail style app) on top of our library. The results of this exercise was very useful. Unfortunately, they were nothing more than spikes, so we can’t deliver them as part Prism, but we are thinking of doing a bunch of blog posts or webcasts, that describe how to build different application styles on top of Prism. &lt;/p&gt;  &lt;p&gt;You can get drop 9 of Prism here: &lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912" href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912"&gt;http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=21912&lt;/a&gt;&lt;/p&gt;  &lt;h1&gt;&amp;#160;&lt;/h1&gt;  &lt;h1&gt;What’s in Prism drop 9&lt;/h1&gt;  &lt;ul&gt;   &lt;li&gt;&lt;strong&gt;New skin for the Stocktrader reference implementation. &lt;/strong&gt;      &lt;br /&gt;We wanted to show a bit more of the power of the WPF and Silverlight platform in our RI, so we have hired an external design bureau to create a new design. It has taken a bit longer to implement than we had hoped. In this drop, we have some of the basic styling in place. Hopefully, we can get the next styling &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Desktop only solutions&lt;/strong&gt;       &lt;br /&gt;Not everybody is interested in developing on both WPF and Silverlight. So that’s why we’ve added ‘WPF’ only solutions. We can’t really add Silverlight only solutions as easily, because the Silverlight projects are linking all the files from the WPF projects. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;New SingleActiveWindowRegionAdapter in the RI        &lt;br /&gt;&lt;/strong&gt;We are demonstrating how to create an adapter in the RI, in this case how to create a popup window and use that as a region. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Several bugs fixed        &lt;br /&gt;&lt;/strong&gt;Lots of testing, prioritizing, bugfixing, retesting, etc.. &lt;/li&gt;    &lt;li&gt;&lt;strong&gt;Exception stack compression in combination with Unity        &lt;br /&gt;&lt;/strong&gt;Unity is an awesome DI container, but it doesn’t give really clear exception messages if something goes wrong. &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;The last weeks of a project are always interesting. There are _so_ many ‘little’ things we would have wanted do do, or add to the library. but what seems like a small dev effort, can quickly add up if you also count the test and doc effort. So, we are constantly keeping a critical eye on our prioritized backlog of tasks. Unfortunately, this means there are a bunch of really interesting stuff we would have loved to tackle, but we can’t. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;Exception stack compression&lt;/h1&gt;  &lt;p&gt;While building different application styles on top of Prism, we found an interesting problem. &lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Suppose the following example: You are creating a simple view. In the Module.Initialize(), you are registering the type of the view against a region that’s displayed in the shell. In the constructor of the view, you have made a small programming error, which causes an exception. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;So what’s the result?&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;A module initialize error. Ok, that makes sense. But what was the exception message inside that? &lt;em&gt;“Exception occurred at target of invocation.”.&lt;/em&gt; And inside that? A bunch of ServiceLocator, Unity and Objectbuilder errors. Only somewhere at the bottom of the inner exception list you find the exception that caused the problem. &lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;All these exceptions are perfectly valid from a technical point of view, but not very useful in understanding what’s going wrong.&amp;#160; Ideally, Unity should return a very clear exception message: “Tried to create object X, but could not because of this error message: ‘xyz’”. Unfortunately, Unity does not do this. (After a discussion with the enterprise library team, it turns out that it’s really hard to build this in Unity). I think that developers who are building applications on top of Prism are rarely interested how exactly the DI container builds up it’s objects.&amp;#160; So all the technical inner exceptions are just clutter to them, that’s obscuring what’s really going wrong. &lt;/p&gt;  &lt;p&gt;So we have built some logic to try and find the error in the stack trace that actually points developers in the right direction. The goal was to be able to get the following exception message: “An exception occurred while initializing module X, in the constructor of View X, with exception message “XYZ”. &lt;/p&gt;  &lt;p&gt;So now in Prism, you can use the extension method exception.GetRootException() to try and find the exception that’s actually causing the problem. It won’t be 100% accurate, but it looks like it really helps in getting to the root of the problem more quickly. &lt;/p&gt;  &lt;p&gt;Hopefully you will find this useful to!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9340600" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Prism/default.aspx">Prism</category></item><item><title>PRISM v2 – dROP 6 (Composite Application Guidance for WPF and Silverlight</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2008/11/22/prism-v2-drop-6-composite-application-guidance-for-wpf-and-silverlight.aspx</link><pubDate>Sat, 22 Nov 2008 04:48:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9132493</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9132493.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9132493</wfw:commentRss><description>&lt;p&gt;Today, we have released the 6th drop of Prism V2 (affectionately known as Compostite Application Guidance for WPF and Silverlight)&lt;/p&gt;  &lt;p&gt;You can download it from:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=19731" href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=19731"&gt;http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=19731&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;What’s new?&lt;/h1&gt;  &lt;p&gt;We’ve had a busy iteration, where we mainly focused on improving some of the design around regions, bugfixes and some code cleanup. This is the list of new items:&lt;/p&gt;  &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; • RegionContext usable in XAML.    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Introduced a façade on IRegionManager for adding views to regions (push based) and registering view types (pull based)     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Expanded the usage of pull based composition in Top Down Composition quickstart     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Silverlight RI is now using the Silverlight Toolkit Controls for line and pie charts     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Regions and RegionContext using an expanded behavior mechanisms     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Have established package load key for project linker     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; • known issue: this still requires the SDK to be installed, however.     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Changed to Add Project Link... dialog     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Resolved a number of code-analysis rules     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • Stock Trader RI is now using pull-view (or top-down) composition for trend line graph     &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; • ProjectLinker installer does not have to be started with elevated permissions on Vista&lt;/p&gt;  &lt;p&gt;So like always, please check it out and tell us what you think. &lt;/p&gt;  &lt;p&gt;There are a couple of topics I’d like to go into a bit deeper:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;Façade on IRegionManager&lt;/h1&gt;  &lt;p&gt;We’ve introduced a façade on the IRegionManager to make it a bit easier to work with Regions, either from a push or pull based perspective. You can use the following calls:&lt;/p&gt;  &lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;   &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;     &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; MyModule : IModule&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; Initialize()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// Push based composition&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// This code will find &amp;quot;Region1&amp;quot; (it must already be created) and add a new &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// instance of MyView to it. &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.regionManager.AddViewToRegion(&lt;span style="color: #006080"&gt;&amp;quot;Region1&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MyView());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// Pull based composition&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// This code will register a viewtype with a region. Whenever Region2 is &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// displayed, it will automatically be populated by a new instance of MyView()&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// created by the ServiceLocator. &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.regionManager.RegisterTypeWithRegion(&lt;span style="color: #006080"&gt;&amp;quot;Region2&amp;quot;&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;typeof&lt;/span&gt;(MyView());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  17:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// Variation on pull based composition:&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  18:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// This code uses a delegate that creates the view to be pulled. This is great&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  19:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// if your presenters are responsible for creating the views. &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  20:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.regionManager.RegisterTypeWithRegion(&lt;span style="color: #006080"&gt;&amp;quot;Region2&amp;quot;&lt;/span&gt;, &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  21:&lt;/span&gt;                () =&amp;gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MyViewPresenter().View());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  22:&lt;/span&gt;         &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  23:&lt;/span&gt;     }   &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  24:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  25:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;private&lt;/span&gt; IRegionManager regionManager;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  26:&lt;/span&gt;     &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  27:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; MyModule(IRegionManager regionManager)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  28:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  29:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.regionManager = regionManager;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  30:&lt;/span&gt;     }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  31:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  32:&lt;/span&gt; }&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;In the previous drop, we have introduced the IRegionViewRegistry, where you could register views to be pulled (Previously called RegionContentRegistry). This allows you to plug in your own registration module. However, we figured that for simple scenario’s, you don’t need to know about this implementation detail. &lt;/p&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h1&gt;RegionContext&lt;/h1&gt;

&lt;p&gt;An other thing we’ve improved is the RegionContext. Like I mentioned in my previous blogpost, the RegionContext is a way that a view that hosts a region can share some of it’s information with any childviews that are loaded into it’s region. The RegionContext now supports 2 way databinding and is very configurable using RegionBehaviors. &lt;/p&gt;

&lt;p&gt;The following codesnippet shows how to use the RegionContext in XAML:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ContentControl&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Name&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;SelectionPanel&amp;quot;&lt;/span&gt;
                &lt;span style="color: #ff0000"&gt;cal:RegionManager&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;RegionName&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{x:Static local:RegionNames.SelectionRegion}&amp;quot;&lt;/span&gt;
                &lt;span style="color: #ff0000"&gt;cal:RegionManager&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;RegionContext&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Path=SelectedEmployee, Mode=TwoWay}&amp;quot;&lt;/span&gt;
                &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt; &lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;And in the views, you can get access to the regioncontext like this:&lt;/p&gt;

&lt;div&gt;
  &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #008000"&gt;// To get the value from the regioncontext, from inside the view in a region:&lt;/span&gt;
var regionContextValue = RegionExtensions.GetRegionContext(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).Value

&lt;span style="color: #008000"&gt;// To change the RegionContext:&lt;/span&gt;
RegionExtensions.GetRegionContext(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).Value = newValue

&lt;span style="color: #008000"&gt;// And to subscribe to change events:&lt;/span&gt;
RegionExtensions.GetRegionContext(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;).PropertyChanged += RegionContext_PropertyChanged&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h1&gt;RegionBehaviors&lt;/h1&gt;

&lt;p&gt;We’ve received a number of questions from people who liked the functionality where a region would automatically pull in instances of all registered viewtypes. However, they really wanted the ability to influence which views were pulled in. This was one of the reasons why we moved to implement a list of behaviors on a region. &lt;/p&gt;

&lt;p&gt;We had the following requirements:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;You have to be able to define regions in XAML and Code &lt;/li&gt;

  &lt;li&gt;You should be able to bind the RegionContext in XAML or set it through code. &lt;/li&gt;

  &lt;li&gt;The RegionContext should be available for views inside a region. But a view can either be an UserControl (thus a dependencyobject) or a ViewModel (poco) &lt;/li&gt;

  &lt;li&gt;A region should be able to pull in registered views (but in a way you can influence it) &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This lead us to the conclusion a region has a couple of behaviors. We will provide a number of behaviors by default, which you can change globally, or for a specific Region instance. &lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PRISMv2dROP6cOMPOSITEaPPLICATIONgUIDANCE_E156/image_2.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PRISMv2dROP6cOMPOSITEaPPLICATIONgUIDANCE_E156/image_thumb.png" width="343" height="58" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;h1&gt;Default behaviors&lt;/h1&gt;

&lt;p&gt;We have built a number of behaviors:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;For synchronizing the RegionContext, we’ve built two behaviors:&lt;strong&gt; SyncRegionContextBehavior&lt;/strong&gt;, which will synchronize the regioncontext dependency property, defined in XAML with the Context property on the region. To synchronize the Regions Context property with childviews (we only support usercontrols now) we have the &lt;strong&gt;BindRegionContextToDependencyObjectBehavior&lt;/strong&gt;. &lt;/li&gt;

  &lt;li&gt;For the TopDown (pull based) composition, we’ve created the &lt;strong&gt;AutoPopulateBehavior&lt;/strong&gt;. This will query the RegionViewRegistry for all viewtypes defined on the view and autopopulate it. &lt;/li&gt;

  &lt;li&gt;To register the region with the regionmanager, we’ve created the &lt;strong&gt;RegionManagerRegistrationBehavior. &lt;/strong&gt;&lt;/li&gt;

  &lt;li&gt;Some views are aware of the fact that they are ‘active’ or not, by implementing the IActiveAware. The active property is set on them by the &lt;strong&gt;RegionActiveAwareBehavior&lt;/strong&gt;. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This diagram shows the behaviors we have built now:&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PRISMv2dROP6cOMPOSITEaPPLICATIONgUIDANCE_E156/image_6.png"&gt;&lt;img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PRISMv2dROP6cOMPOSITEaPPLICATIONgUIDANCE_E156/image_thumb_2.png" width="777" height="610" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h1&gt;Customizing the behaviors for all regions &lt;/h1&gt;

&lt;p&gt;The default behaviortypes are registered in the UnityBootstrapper. By overriding the ConfigureDefaultRegionBehaviors method you can add new behaviortypes, replace existing types or remove behaviors. You can also choose to register a different IRegionBehaviorFactory, if you require custom initialization for your behaviors. &lt;/p&gt;

&lt;p&gt;The default behaviors are added by the RegionAdapterBase. In the RegionAdapter you can decide to add behaviors for specific control types. For example, we had to build a behavior to get the TabControl in silverlight to work properly. (It doesn’t derive from selector like in WPF). &lt;/p&gt;

&lt;h1&gt;Customizing the behaviors for a single region instance&lt;/h1&gt;

&lt;h2&gt;&lt;/h2&gt;

&lt;p&gt;Sometimes, you want to add a behavior to a specific instance of a region. For example, when you want to change the way views are pulled into a region. To do this, you have to detect that the region has been created, but before the default region behaviors are attached. You can do that by hooking up an eventhandler in the constructor of the view that’s hosting a region. &lt;/p&gt;

&lt;div style="border-bottom: gray 1px solid; border-left: gray 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; max-height: 200px; font-size: 8pt; overflow: auto; border-top: gray 1px solid; cursor: text; border-right: gray 1px solid; padding-top: 4px"&gt;
  &lt;div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;
    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   1:&lt;/span&gt; &lt;span style="color: #008000"&gt;// From the TopDownUIComposition Quickstart&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   2:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; EmployeesView()&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   4:&lt;/span&gt;     InitializeComponent();&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   6:&lt;/span&gt;     RegionExtensions.GetObservableRegion(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.SelectionPanel).PropertyChanged += &lt;span style="color: #0000ff"&gt;delegate&lt;/span&gt;(&lt;span style="color: #0000ff"&gt;object&lt;/span&gt; sender, PropertyChangedEventArgs args)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   7:&lt;/span&gt;     {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   8:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (args.PropertyName == &lt;span style="color: #006080"&gt;&amp;quot;Value&amp;quot;&lt;/span&gt;)&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;   9:&lt;/span&gt;         {&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  10:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// The region has just been created, but (Very Important), the default behaviors have not been added yet. &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  11:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// This gives you a chance to add your own custom behaviors. If you use the same key as a default behavior&lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  12:&lt;/span&gt;             &lt;span style="color: #008000"&gt;// it will replace a default behavior. &lt;/span&gt;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  13:&lt;/span&gt;             IRegion region = RegionExtensions.GetObservableRegion(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.SelectionPanel).Value;&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  14:&lt;/span&gt;             region.Behaviors.Add(AutoPopulateRegionBehavior.BehaviorKey, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomAutoPopulateBehavior());&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  15:&lt;/span&gt;         }&lt;/pre&gt;

    &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060"&gt;  16:&lt;/span&gt;     };&lt;/pre&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;&lt;/p&gt;

&lt;p&gt;The ‘GetObservableRegion’ method will return an object that you can monitor to when the region is created. The .Value property will hold the new region. &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9132493" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category></item><item><title>Prism V2 – Drop 4</title><link>http://blogs.msdn.com/erwinvandervalk/archive/2008/10/24/prism-v2-drop-4.aspx</link><pubDate>Sat, 25 Oct 2008 01:54:53 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9015367</guid><dc:creator>erwinvandervalk</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/erwinvandervalk/comments/9015367.aspx</comments><wfw:commentRss>http://blogs.msdn.com/erwinvandervalk/commentrss.aspx?PostID=9015367</wfw:commentRss><description>&lt;p&gt;&lt;/p&gt;  &lt;p&gt; Today, We have put an other drop of Prism V2 (Composite application guidance for WPF and Silverlight) online. You can download it from here:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=18750" href="http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=18750"&gt;http://www.codeplex.com/CompositeWPF/Release/ProjectReleases.aspx?ReleaseId=18750&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h1&gt;New in Prism V2 - Drop 4&lt;/h1&gt;  &lt;p&gt;This sprint was mainly focused around UI Composition. We have ported the Region functionality from Prism V1 over so it also works in Silverlight. Then we also addressed a different style of visual composition, we’re calling Top Down composition. I’m going to drill into those composition styles later in this post. &lt;/p&gt;  &lt;h1&gt;&amp;#160;&lt;/h1&gt;  &lt;h1&gt;Top down vs. Bottom up composition&lt;/h1&gt;  &lt;p&gt;In the last couple of weeks, we’ve had a lot of discussions around Visual Composition patterns. &lt;/p&gt;  &lt;h2&gt;Bottom up composition&lt;/h2&gt;  &lt;p&gt;Prism V1 used a regions to support Bottom Up composition. As a developer, you can define and name regions on your screen. When developing modules, you can use the names of these regions to push views into the regions. At first, we called this “push” based composition, because modules push their views into named regions. The diagram below shows an example of push based composition. We’re also calling this bottom up composition, because lower level modules push their views into the regions of higher level views. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PrismV2Drop4_DFBC/image_20.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PrismV2Drop4_DFBC/image_thumb_9.png" width="521" height="360" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Although this composition model allows for a highly decoupled and modular approach to UI development, we received some feedback that in some scenario’s it can be a bit to complex. &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;h2&gt;Top down composition&lt;/h2&gt;  &lt;p&gt;With top down composition we took a different approach. Usually, developers are very comfortable with the usage of UserControls. It’s quite common for developers to split up a view into several UserControls to reduce complexity (divide and conquer) and to improve reuse of visual elements. Now it’s quite easy to create controls and place them in different assemblies. However, in order to use those assemblies, the shell has to have a reference to the assemblies that hold the user controls. This goes against the principles of modular development where modules can be versioned, and deployed seperately. &lt;/p&gt;  &lt;p&gt;We wanted to allow a model where you can visually compose your application in the same way as using UserControls, but without sacrificing modularity. To do this, we introduced a Top Down composition model:&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PrismV2Drop4_DFBC/image_22.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/erwinvandervalk/WindowsLiveWriter/PrismV2Drop4_DFBC/image_thumb_10.png" width="512" height="362" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So instead of the shell having a hard reference to the CustomerModule and putting a CustomerView directly on the ShellView, you put a ContentControl in the place where you want the user control. Then you use an attached property ViewType to specify what kind of View you want to display here, by specifying the interface of the view to display. The view interfaces can be defined in a seperate (Interface) module or in the shell. &lt;/p&gt;  &lt;p&gt;When a module get’s initialized, it typically registers it’s views to the &lt;a href="http://msdn.microsoft.com/en-us/library/cc707845.aspx"&gt;DI container&lt;/a&gt;. For example, the CustomerModule will tell the container that it can provide an implementation of the ICustomerView, because it registers the CustomerView type with the ICustomerView interface. Now after module initialization, the ShellView will ask the DI container for an implementation of ICustomerView. This will of course return the CustomerView, so it can then be shown in the ContentControl. Essentially, the ContentControl on the ShellView is pulling the CustomerView in from the CustomerModule, without having a direct reference to that module. We are calling this “Top Down” composition, because the Higher level modules define which views are displayed where. &lt;/p&gt;  &lt;p&gt;This is an example (from the TopDownCompositionQuickstart) on how you specify a view that’s pulled into the shell in XAML:&lt;/p&gt;  &lt;div&gt;   &lt;pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, &amp;#39;Courier New&amp;#39;, courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ContentControl&lt;/span&gt; 
    &lt;span style="color: #ff0000"&gt;Regions:ContentController&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;ViewType&lt;/span&gt;=
         &lt;span style="color: #0000ff"&gt;&amp;quot;TopDownComposition.Modules.Employee.IEmployeesListView, EmployeeModule.Silverlight, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;You might notice 2 things:&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;&lt;strong&gt;The viewtype is a string
      &lt;br /&gt;&lt;/strong&gt;At first we wanted to use the type of the interface directly. Unfortunately, this doesn’t work in Silverlight, because you cannot create types in XAML, because {x:Type} doesn’t work. But working with strings isn’t too bad. We’re planning to make the resolving logic pluggable. This way, you could for example use logical names, exported by your modules, to identify and retrieve the views. In fact, the &lt;a href="http://code.msdn.microsoft.com/mef"&gt;MEF framework&lt;/a&gt; also works like that. 

    &lt;br /&gt;&lt;/li&gt;

  &lt;li&gt;&lt;strong&gt;The viewtype is a really long string
      &lt;br /&gt;&lt;/strong&gt;To make working with those really long strings a bit more bearable, we’re also thinking of building a custom type resolver. Since 99.9% of the times the full typename (Namespace.TypeName) is unique, you can get away with just specifying that and let the framework figure out which assembly the type came from.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We’re also considering moving the View resolving functionality from the ContentController to the RegionManager. Even though technically this has nothing to do with regions, conceptually it’s very similar. A region specifies where you want to display visual elements from other modules. In the top down approach, you specify the content via it’s interface and in the bottom up approach you give it a name so others can push views into it. But it’s still a placeholder for views. &lt;/p&gt;

&lt;h2&gt;Conclusion&lt;/h2&gt;

&lt;p&gt;Hopefully you’ve found this post useful in explaining what we’re building. As always, we are very open to feedback. If you don’t like something we do, please tell us! Also if you do like something, tell us that as well! It might just prevent us from changing something you are already happy with :) &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9015367" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/CAL/default.aspx">CAL</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Design+Patterns/default.aspx">Design Patterns</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/patterns+_2600_amp_3B00_+practices/default.aspx">patterns &amp;amp; practices</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/WPF/default.aspx">WPF</category><category domain="http://blogs.msdn.com/erwinvandervalk/archive/tags/Silverlight/default.aspx">Silverlight</category></item></channel></rss>