<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-19967453</id><updated>2012-01-25T10:05:47.331-08:00</updated><category term='Code Snippets'/><category term='DLR'/><category term='SWT Browser'/><category term='Article'/><category term='startup'/><category term='Java 7'/><category term='projects'/><category term='Tutorial'/><category term='Dave'/><category term='Java'/><category term='VB'/><category term='Groovy'/><category term='Programming'/><category term='C++'/><category term='C#'/><category term='early adoption'/><category term='freelance work'/><category term='screencasts'/><category term='Interviews'/><category term='Tools'/><category term='WPF Forum Questions'/><category term='IronPython'/><category term='closures'/><category term='WPF'/><category term='Tricks'/><category term='.NET 3.5'/><title type='text'>Musings of a Software Developer</title><subtitle type='html'>by Krishna Vangapandu</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default?start-index=101&amp;max-results=100'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>188</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-19967453.post-375177639084953958</id><published>2011-12-12T18:20:00.001-08:00</published><updated>2011-12-12T18:20:58.472-08:00</updated><title type='text'>Real World Example : Simple Publish/Subscribe Pattern with Reactive Extensions</title><content type='html'>&lt;p&gt;Shown below is a requirement. &lt;br&gt;&lt;script src="https://gist.github.com/1470033.js?file=EventThrottlingTest.cs"&gt;&lt;/script&gt;&lt;br&gt;Let me explain a little about what I want to achieve. I have an entity called “Frequent” which implements INotifyPropertyChanged interface. So I can subscribe to the change notification and then upon firing the event, I simply increment a counter. Now, my requirement is that the PropertyChanged can fire way too quickly as simulated in the for-loop. So in UI applications, it doesn’t make sense for me to fire property changed events that frequently as in a real world intensive WPF application, this can become your biggest bottleneck (among several others things). &lt;/p&gt; &lt;p&gt;So my requirement is that, within 1 second, I would like to receive only 1 change notification per property, if it has changed indeed. The simple implementation for this would be to do something like pushing the properties that have changed into a queue and process the queue once a second and then raise change notification event. This can be done very easily but then it can be a little tedious job for such a requirement to restrict an event from firing more than X times a second. &lt;/p&gt; &lt;p&gt;So I was looking at the Reactive Extensions (Rx Framework) and it occurred to me that it should support Observer pattern out of the box. So I started playing with it but hit a road block immediately. There are numerous resources that shows how to generate observables from Timers, Time Intervals, Enumerables, etc but what I want to is to take advantage of extension methods supported by Rx Framework on IObserver such as Throttle(), Buffer(), Window(), etc on a simple Pub-Sub system. May be I did not look hard enough but I could not find a simple example. So I thought it would be helpful for rest of the people like me if I made a blog post.&lt;/p&gt; &lt;p&gt;In my implementation, the Frequent object is by itself a Publisher and a Subscriber. In Rx terms – IObservable and IObserver. Instead of implementing these interfaces, I want to have some observable of strings where I will publish a property that has changed and the subscriber on the observable would receive it. So for that purpose of simple message passing between Observers and Observables, you can use a Subject&amp;lt;T&amp;gt;. There are other variants like ReplaySubject&amp;lt;T&amp;gt;, BehaviorSubject&amp;lt;T&amp;gt;, AsyncSubject&amp;lt;T&amp;gt;, etc. but that is out of scope of this post. I publish on Subject&amp;lt;T&amp;gt; and then the subscribers who subscribed earlier to it would be notified of these messages.&lt;/p&gt; &lt;p&gt;Shown below is a the Frequent class implementation.&lt;/p&gt; &lt;p&gt;&lt;script src="https://gist.github.com/1470125.js?file=Frequent.cs"&gt;&lt;/script&gt;&lt;/p&gt; &lt;p&gt;Take a minute or two to go through the simple class, it is self explanatory. All I am doing is that when a property changes, instead of firing it immediately, I simply notify my throttler about the property that has changed. The throttler’s responsibility is to determine when to notify the subscribers about this change. Shown below is the implementation.&lt;/p&gt; &lt;p&gt;&lt;script src="https://gist.github.com/1470141.js?file=StringMessageThrottler.cs"&gt;&lt;/script&gt;&lt;/p&gt; &lt;p&gt;You can read my comments that I wrote out of frustrations. All I do in this simple façade is to wrap an Observable –&amp;gt; Subject&amp;lt;string&amp;gt; and buffer the messages received for 1/2 second and then get unique messages from the buffer and publish it to the subscribers. This is all done in the constructor. The other methods are simply my take on making things simple for the consumer of this class.&lt;/p&gt; &lt;p&gt;Rx is complex and powerful but in my opinion it has a very steep learning curve. But it surely did save a good few days of implementation for my team. Again, I am very new to Rx, so if you have some better ways to do it, then please let me know.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-375177639084953958?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/375177639084953958/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=375177639084953958' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/375177639084953958'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/375177639084953958'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2011/12/real-world-example-simple.html' title='Real World Example : Simple Publish/Subscribe Pattern with Reactive Extensions'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1391339707107645038</id><published>2011-12-09T19:51:00.001-08:00</published><updated>2011-12-09T19:51:24.592-08:00</updated><title type='text'>Hannspad Hannspree SN10T2 – Rooting, Android Market and Some Crazy stuff</title><content type='html'>&lt;p&gt;Recently the Android Tablet bug bit me which led me to buy Hannspad Hannspree SN10T2 from AliExpress.com. The order was made on the day of Thanksgiving and I received the tablet within two weeks. The whole goal was to get a cheap tablet on which I can try installing custom ROM, may be try and develop some applications. But turns out it is not that simple. See the Slatedriod.com forums has custom ROM but for SN10T1 model but not SN10T2 model – which runs on two different processors. So all the cool stuff I read about that people do with SN10T1 is not applicable for SN10T2 – example being booting the tablet in recovery mode. There are not hard volume buttons that lets me boot into recovery console. I tried all different combinations instead of missing Volume + button but the recovery key sequence remains unknown.&lt;/p&gt; &lt;h2&gt;&lt;/h2&gt; &lt;h2&gt;Connecting the Hannspad Tablet to Windows 7 x64&lt;/h2&gt; &lt;p&gt;Hooking up the USB cable to the Windows 7 machine doesn’t really install the drivers. You can still be able to copy files around once you enable the USB File Transfer on the tablet. If you are new like me, just drag the notifications bar on top of the tablet and the instructions then are clear enough for you to know what to do. So first time you hook up the tablet, you get the message saying OMAP-3/4 driver is not found. Don’t even fight it, there is a really simple way to install the driver for the tablet.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Download Super One Click from Shortfuse.org. The direct link to what I am using is &lt;a href="http://www.multiupload.com/VGCN3ZTFM8" target="_blank"&gt;here.&lt;/a&gt; It is version 2.3.1.&lt;/li&gt; &lt;li&gt;Extract the zip file to some place you have your portable applications. I put it in temp but now I have a problem deleting the folder because driver was installed from this location??&lt;/li&gt; &lt;li&gt;Launch SuperOneClick.exe and then click on Advanced Tab.&lt;/li&gt; &lt;li&gt;Click on Check Driver.&lt;/li&gt; &lt;li&gt;Then say OK for installation of the driver.&lt;/li&gt; &lt;li&gt;Accept Windows warning about unsigned driver and move on.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;What this driver lets you do is to let ADB (Android Debug Bridge or visualize like a remote shell access for your tablet unix system) identify that this device is hooked up and running.&lt;/p&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h2&gt;Rooting the SN10T2 (may work for other tablets too!)&lt;/h2&gt; &lt;p&gt;If you search for information on how to root the SN10T2, the first thing you see is the article by &lt;a href="http://tabletrepublic.com/forum/hannspad/hannspad-sn10t2-easy-rooting-google-apps-guide-143.html" target="_blank"&gt;Sir Shagsalot&lt;/a&gt; (&lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-winkingsmile" alt="Winking smile" src="http://lh6.ggpht.com/-FCWo0OcWuXg/TuLXM444_NI/AAAAAAAABcs/RhwNRvmp0GY/wlEmoticon-winkingsmile%25255B2%25255D.png?imgmax=800"&gt;). It has precisely what you need to do in order to enable Super User access for the programs running on your Android Tablet. Since the information is not so eye-soothing, I will try to replicate the information. But be aware &lt;/p&gt; &lt;ol&gt; &lt;li&gt;The information here is from the article I mentioned above plus my experience struggling with the Tablet.&lt;/li&gt; &lt;li&gt;I am not an Android Expert – I am just a software developer who writes software for a living mostly on Windows Platform.&lt;/li&gt; &lt;li&gt;Don’t blame me for any physical or mental or financial pain that may cause as a result of following this information.&lt;/li&gt; &lt;li&gt;Rooting implies the warranty is void. You cannot bitch about your tablet to your vendor anymore. Not my problem again &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh5.ggpht.com/-B3_Y66zUzlE/TuLXNMkqz9I/AAAAAAAABc0/46RWP-R0B5o/wlEmoticon-smile%25255B2%25255D.png?imgmax=800"&gt;&lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;Option 1 : Using the same SuperOneClick&lt;/h3&gt; &lt;p&gt;If you followed the previous steps, you can use SuperOneClick to Root your device. &lt;/p&gt; &lt;h3&gt;Option 2 : Using &lt;a href="http://forum.xda-developers.com/showthread.php?t=833953" target="_blank"&gt;z4Root&lt;/a&gt;&amp;nbsp;&lt;/h3&gt; &lt;ol&gt; &lt;li&gt;Download the z4root.apk and place it in your SD Card on the tablet.&lt;/li&gt; &lt;li&gt;On the tablet, go to Menu-&amp;gt;Settings-&amp;gt;Application Settings and check the option for Unknown Sources.&lt;/li&gt; &lt;li&gt;Now go to Home-&amp;gt;Applications-&amp;gt;ES File Explorer.&lt;/li&gt; &lt;li&gt;Navigate to the z4root.apk wherever you copied it.&lt;/li&gt; &lt;li&gt;Install the APK file.&lt;/li&gt; &lt;li&gt;Then open the z4root application.&lt;/li&gt; &lt;li&gt;You will see two options –&amp;gt; Temporary Root or Permanent Root. If your application is already rooted, you will see the option to Unroot.&lt;/li&gt; &lt;li&gt;I selected Permanent Root.&lt;/li&gt; &lt;li&gt;Then wait until you see “Rebooting..”. If the tablet doesn’t reboot in say 10 minutes, I would not bother to wait. Just restart the tablet manually. It is fine!&lt;/li&gt;&lt;/ol&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;The Android SDK Tools&lt;/h3&gt; &lt;p&gt;Basically, rooting gives you Super user access and lets you access the shell from ADB console. The super one click application distributes the ADB console application if you poke inside the installation folder. &lt;/p&gt; &lt;p&gt;Anyway for you to officially get the ADB application, you can download the Android SDK from &lt;a href="http://developer.android.com/sdk/index.html" target="_blank"&gt;here.&lt;/a&gt;&amp;nbsp;&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Download the &lt;a href="http://developer.android.com/sdk/index.html" target="_blank"&gt;Android SDK.&lt;/a&gt;&lt;/li&gt; &lt;li&gt;Download the &lt;a href="http://www.oracle.com/technetwork/java/javase/downloads/index.html" target="_blank"&gt;Java Development Kit&lt;/a&gt;, if you don’t have it already. You need JDK not JRE.&lt;/li&gt; &lt;li&gt;Install JDK. Install Android SDK.&lt;/li&gt; &lt;li&gt;Now in the Android folder (C:\Program Files(x86)\Android\android_sdk\), launch the SDK Manager application. See image below.&lt;/li&gt; &lt;li&gt;You need to check “Android SDK Tools” and then click “Install Packages”.&lt;/li&gt; &lt;li&gt;Once done, you will find a folder called “platform-tools”.&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;&lt;a href="http://lh4.ggpht.com/-juGMnplne4M/TuLXNYHUJ8I/AAAAAAAABc8/O7t83ulPnLw/s1600-h/image%25255B3%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh4.ggpht.com/-8YQOmn5pJFQ/TuLXNr8DPBI/AAAAAAAABdE/uFnJXm6yX94/image_thumb%25255B1%25255D.png?imgmax=800" width="352" height="253"&gt;&lt;/a&gt;&lt;/p&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;Some fun with ADB.&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;Open command prompt and assuming platform-tools is in your PATH. &lt;strong&gt; &lt;h3&gt;&lt;strong&gt;(Of course, the table is connected to the machine, USB Debugging enabled on the tablet).&lt;/strong&gt;&lt;/h3&gt;&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Listing all the devices – &lt;strong&gt;adb devices&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Opening the Unix Shell for your tablet – &lt;strong&gt;adb shell&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Copying files from your PC to the device&lt;/li&gt; &lt;ul&gt; &lt;li&gt;For SD Card, you don’t need to mount as it is already mounted for “Read-Write”. Just run the command - &lt;/li&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;adb push c:\myfiles\superdocument.pdf /sdcard/&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;For copying to /system/app folder, which you may have to do for manual installation of Google Apps and Market&lt;/li&gt; &lt;ul&gt; &lt;li&gt;Go to the shell of tablet using “adb shell”. Now inside the shell,&lt;/li&gt; &lt;li&gt;Mount the /system using the command&lt;/li&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;mount -o remount,rw /dev/block/mmcblk0p5 /system&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Copy the files you want to push to /system/app, using&lt;/li&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;push c:\files\superapp.apk /system/app/&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Unmount the /system using the command&lt;/li&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;mount -o remount,ro /dev/block/mmcblk0p5 /system&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Make sure you unmount once you are done.&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;li&gt;Reboot the tablet from Windows – &lt;strong&gt;adb reboot&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Copying files from your tablet to the PC – &lt;strong&gt;adb pull \sdcard\super.pdf c:\temp\goodbook.pdf&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt; &lt;h3&gt;&lt;/h3&gt; &lt;h3&gt;Installing the Android Market on the SN10T2&lt;/h3&gt; &lt;p&gt;You can follow the original instructions from top to bottom &lt;a href="http://tabletrepublic.com/forum/hannspad/hannspad-sn10t2-easy-rooting-google-apps-guide-143.html" target="_blank"&gt;that Sir ShagsALot wrote here.&lt;/a&gt; I will just use the ADB to install the Android Market application.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Root your tablet either using SuperOneClick or Z4Root as described previously. Reboot your tablet.&lt;/li&gt; &lt;li&gt;Download the required Google Apps distribution from the link mentioned in the article.&lt;/li&gt; &lt;li&gt;Extract them to some place on your machine.&lt;/li&gt; &lt;li&gt;Make sure ADB is in your PATH. Open the Command Prompt and navigate to the folder where you extracted the googleapps.rar archive.&lt;/li&gt; &lt;li&gt;You should see something like shown below.&lt;/li&gt;&lt;/ul&gt; &lt;p align="center"&gt;&lt;a href="http://lh6.ggpht.com/--K5PbEsjGPE/TuLXNyxwHjI/AAAAAAAABdM/OvNG4Unppdk/s1600-h/image%25255B7%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh3.ggpht.com/-n8nlnzr5QDw/TuLXOQTTgUI/AAAAAAAABdU/v1sQYmVsMgg/image_thumb%25255B3%25255D.png?imgmax=800" width="442" height="150"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Navigate the command prompt into the “app” folder.&lt;/li&gt; &lt;li&gt;Using the ADB shell, first mount the /system on your tablet. Then run the following commands to push APK files to /system/root/&lt;/li&gt; &lt;ul&gt; &lt;li&gt;&lt;strong&gt;c:\temp\Working Google Apps\app&amp;gt; adb push GoogleServicesFramework.apk /system/app&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;c:\temp\Working Google Apps\app&amp;gt; adb push OneTimeInitializer.apk /system/app&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;c:\temp\Working Google Apps\app&amp;gt; adb push SetupWizard.apk /system/app&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;strong&gt;c:\temp\Working Google Apps\app&amp;gt; adb push com.android.vending.apk /system/app/Vending.apk &lt;/strong&gt;&lt;/li&gt; &lt;li&gt;&lt;em&gt;Notice the Application for Market is renamed to Vending.apk (don’t think you need to do this, but everyone else uses Vending.apk) &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://lh5.ggpht.com/-B3_Y66zUzlE/TuLXNMkqz9I/AAAAAAAABc0/46RWP-R0B5o/wlEmoticon-smile%25255B2%25255D.png?imgmax=800"&gt;&lt;/em&gt;&lt;/li&gt; &lt;li&gt;&lt;em&gt;Shown below is the command prompt snapshot for your reference&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt; &lt;p&gt;&lt;a href="http://lh3.ggpht.com/-3ksg9WUaeKg/TuLXOjX6YqI/AAAAAAAABdc/XXfFRrvnt98/s1600-h/image%25255B17%25255D.png"&gt;&lt;img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="image" border="0" alt="image" src="http://lh5.ggpht.com/-qTY5DsnRFOU/TuLXO3TXWSI/AAAAAAAABdk/CY8aBakyORg/image_thumb%25255B7%25255D.png?imgmax=800" width="649" height="376"&gt;&lt;/a&gt;&lt;/p&gt; &lt;ul&gt; &lt;li&gt;From the above you should have understand by now that I am only interested in making the Android Market work. &lt;/li&gt; &lt;li&gt;&lt;strong&gt;Don’t forget to un-mount the /system and also reboot the device as soon as you are done copying.&lt;/strong&gt;&lt;/li&gt; &lt;li&gt;Once the tablet boots, you will be seeing a welcome screen.&lt;/li&gt; &lt;li&gt;Just go through the welcome screen and add your google account.&lt;/li&gt; &lt;li&gt;Now go to Market and make sure it runs.&lt;/li&gt;&lt;/ul&gt; &lt;h4&gt;&lt;/h4&gt; &lt;h3&gt;Some issues that I had &lt;/h3&gt; &lt;ul&gt; &lt;li&gt;ES File Explorer –&amp;gt; Menu –&amp;gt; Settings –&amp;gt; Root Options. Check the “Root Explorer” failed with message &lt;strong&gt;"sorry, test failed. This feature cannot run on your phone” &lt;/strong&gt;message. So what is the alternative ? Use ADB, it might sound intimidating but it is just a simple Shell prompt. If you are messing around your tablet, most likely you are comfortable with the command prompt.&lt;/li&gt; &lt;li&gt;There is a great tool called “File Expert”. It is one tool that impressed me a lot! It is similar to ES File Explorer but much better looking and much easier and intuitive to use. You can upload files from your PC without having to connect your tablet.&lt;/li&gt; &lt;ul&gt; &lt;li&gt;Install File Expert. You can get it from the App Center that ships with the SN10T2 as well.&lt;/li&gt; &lt;li&gt;Launch File Expert. Go to “Share my contents”.&lt;/li&gt; &lt;li&gt;Just touch on the “Share via Web” option. Viola! &lt;/li&gt; &lt;li&gt;Now you should see a brief message explaining how you can access your tablet SD Card from the Web Browser.&lt;/li&gt;&lt;/ul&gt; &lt;li&gt;Uploading multiple files from File Expert Web UI. You cannot upload more than one file when you are in the root of the SD Card. But create one folder and then you would be able to upload multiple files simultaneously. &lt;/li&gt; &lt;li&gt;MOUNT Options in File Expert does not work and can make you believe that it worked. So what is the alternative?? Use ADB.&lt;/li&gt; &lt;li&gt;If you manually move some files to /system/app in File Expert of ES File Manager, you may believe it was successfully copied, but they aren’t really done. You don’t see an error that /system has to be mounted. &lt;/li&gt; &lt;li&gt;If you are messing with different versions of Google Apps, the one in the link by Sir ShagsALot is the only one I found to be working. If you mess up, then remove the APK files from the /system/app manually. &lt;/li&gt; &lt;li&gt;I copied bad APK files and was stuck with Emergency dial screen. So what I realized later was that SetupWizard was badly renamed. So I removed the APK files and copied them keeping the name intact.&lt;/li&gt; &lt;li&gt;Again, if you are stuck with wizard screen and reboot doesn’t help, use ADB to delete the APK file.&lt;/li&gt; &lt;li&gt;Android Market app is installed but launches and dies immediately. You need to make sure GoogleServicesFramework.apk is properly installed/copied into /system/app folder. When in doubt, repeat the process after taking some break.&lt;/li&gt; &lt;li&gt;Android Market App launches but cannot download application. The application page seems to be stuck at “Starting download…”. This only happened when I installed incompatible version of Android App Market.&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;So these are all the things that I struggled with this week and I hope anyone like me who is new to Android Rooting may find this information helpful. By the way, don’t forget to check out &lt;a href="http://www.slatedroid.com/" target="_blank"&gt;SlateDroid&lt;/a&gt;. They are awesome!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1391339707107645038?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1391339707107645038/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1391339707107645038' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1391339707107645038'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1391339707107645038'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2011/12/hannspad-hannspree-sn10t2-rooting.html' title='Hannspad Hannspree SN10T2 – Rooting, Android Market and Some Crazy stuff'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-FCWo0OcWuXg/TuLXM444_NI/AAAAAAAABcs/RhwNRvmp0GY/s72-c/wlEmoticon-winkingsmile%25255B2%25255D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1207177378276928876</id><published>2011-01-16T15:14:00.001-08:00</published><updated>2011-01-16T15:14:16.216-08:00</updated><title type='text'>WPF Events to Command redirection using System.Windows.Interactivity</title><content type='html'>&lt;p&gt;&lt;a href="http://krishnabhargav.blogspot.com/2011/01/executing-routedcommand-in-code-behind.html" target="_blank"&gt;As mentioned previously&lt;/a&gt;, I recently used System.Windows.Interactivity library to make a command respond to an event on WPF controls without using any code-behind. In this post, I would give a brief overview and show some code on how to do it. I will try and keep the post to the point and not write anything about hooking up events with code or anything like that. Usual disclaimer applies – I am not entirely familiar with the internals but I know how to make it work and why it works.&lt;/p&gt; &lt;p&gt;So lets start with my simple requirement. I have a text box and as I enter I want to fire a command which processes the text and displays it on a textblock. Of course you can hook up both the controls to the same property in the ViewModel and with .NET 4.0 you can be sure that the getter will fire again when NotifyPropertyChanged is fired. But that is not the point here. &lt;/p&gt; &lt;p&gt;My XAML would simply have a textbox and a textblock. On textbox.TextChanged event fired, I would like to execute a command in my view model. The XAML is shown below.&lt;/p&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;UserControl x:Class="Buddi.Training.Advanced.Interactivity.EventToCommandDemo"&lt;br /&gt;    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;br /&gt;             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&lt;br /&gt;             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" &lt;br /&gt;             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" &lt;br /&gt;             xmlns:local="clr-namespace:Buddi.Training.Infra"&lt;br /&gt;             xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"&amp;gt;&lt;br /&gt;    &amp;lt;Grid Background="Beige"&amp;gt;&lt;br /&gt;        &amp;lt;Grid.RowDefinitions&amp;gt;&lt;br /&gt;            &amp;lt;RowDefinition Height="100"/&amp;gt;&lt;br /&gt;            &amp;lt;RowDefinition Height="100"/&amp;gt;&lt;br /&gt;        &amp;lt;/Grid.RowDefinitions&amp;gt;&lt;br /&gt;        &amp;lt;TextBox Text="{Binding SampleCommandParam,UpdateSourceTrigger=PropertyChanged}" Margin="20"&amp;gt;&lt;br /&gt;            &amp;lt;i:Interaction.Triggers&amp;gt;&lt;br /&gt;                &amp;lt;i:EventTrigger EventName="TextChanged"&amp;gt;&lt;br /&gt;                    &amp;lt;local:EventToCommand Command="{Binding SampleCommand}"&lt;br /&gt;                                      CommandParameter="{Binding SampleCommandParam}"/&amp;gt;&lt;br /&gt;                &amp;lt;/i:EventTrigger&amp;gt;&lt;br /&gt;            &amp;lt;/i:Interaction.Triggers&amp;gt;&lt;br /&gt;        &amp;lt;/TextBox&amp;gt;&lt;br /&gt;        &amp;lt;TextBlock Text="{Binding Message}" Grid.Row="1" Padding="30" FontFamily="Consolas" FontWeight="14"/&amp;gt;&lt;br /&gt;    &amp;lt;/Grid&amp;gt;&lt;br /&gt;&amp;lt;/UserControl&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; You need to see how I am hooking up the event to the command in viewmodel which is the DataContext of the View (UserControl to be precise). Lets disect what we have here - We add an event trigger to the TriggersCollection on the Grid using the Interactivity.Triggers attached properties. An event trigger comes with the System.Windows.Interactivity.dll assembly. So add a reference to that library using the "Add Reference" dialog. The Event Trigger then expects an action that can be anything that derives from the &lt;a href="http://msdn.microsoft.com/en-us/library/ff726548(v=Expression.40).aspx" target="_blank"&gt;TriggerAction&amp;lt;FrameworkElement&amp;gt;&lt;/a&gt; class. The TriggerAction&lt;T&gt; derived class should implement one method called "InvokeCommand(object parameter)". The implementation simply takes care of executing the command which are passed to the DependencyProperty we defined in the EventToCommand class. Note that TriggerAction&lt;FrameworkElement&gt; is a DependencyObject, thereby it allows you define Dependency Properties to take full advantage of the Binding, Styles, Animations and what not. So the trigger action is simple - (the following is a special implementation where I handle RoutedCommand different than the others, this is just my scenario and is typically bad - you are programming to the implementation which is not a good idea, but the plan here is to show how you can use the base.AssociatedObject).&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;namespace Buddi.Training.Infra&lt;br /&gt;{&lt;br /&gt;    public class EventToCommand : TriggerAction&amp;lt;FrameworkElement&amp;gt;&lt;br /&gt;    {&lt;br /&gt;        public ICommand Command&lt;br /&gt;        {&lt;br /&gt;            get { return (ICommand)GetValue(CommandProperty); }&lt;br /&gt;            set { SetValue(CommandProperty, value); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public static readonly DependencyProperty CommandProperty =&lt;br /&gt;            DependencyProperty.Register(&amp;quot;Command&amp;quot;, typeof(ICommand), typeof(EventToCommand), new UIPropertyMetadata(null));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        public object CommandParameter&lt;br /&gt;        {&lt;br /&gt;            get { return (object)GetValue(CommandParameterProperty); }&lt;br /&gt;            set { SetValue(CommandParameterProperty, value); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        // Using a DependencyProperty as the backing store for CommandParameter.  This enables animation, styling, binding, etc...&lt;br /&gt;        public static readonly DependencyProperty CommandParameterProperty =&lt;br /&gt;            DependencyProperty.Register(&amp;quot;CommandParameter&amp;quot;, typeof(object), typeof(EventToCommand), new UIPropertyMetadata(null));&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;        protected override void Invoke(object parameter)&lt;br /&gt;        {&lt;br /&gt;            if (Command == null) return;&lt;br /&gt;            if (Command is RoutedCommand)&lt;br /&gt;            {&lt;br /&gt;                var rc = Command as RoutedCommand;&lt;br /&gt;                if (rc.CanExecute(CommandParameter, base.AssociatedObject))&lt;br /&gt;                {&lt;br /&gt;                    rc.Execute(CommandParameter, base.AssociatedObject);&lt;br /&gt;                }&lt;br /&gt;            }&lt;br /&gt;            else&lt;br /&gt;            {&lt;br /&gt;                if (Command.CanExecute(CommandParameter))&lt;br /&gt;                    Command.Execute(CommandParameter);&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That's it! you can now program to the events using the commands that you already have. This lets you keep your code-behind clean and write more testable code than ever. I hope this is useful inspite of it not being the best of the articles. By the way, almost every MVVM framework out there provides an implementation of Event To Command action -eg : Caliburn, Cinch, you name it ... but not always it is possible for us to use a third party framework just for this one reason. In such cases, I thought it is good to know that you can acheive it just by using Microsoft's assembly.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1207177378276928876?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1207177378276928876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1207177378276928876' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1207177378276928876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1207177378276928876'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2011/01/wpf-events-to-command-redirection-using.html' title='WPF Events to Command redirection using System.Windows.Interactivity'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-5422809560741155791</id><published>2011-01-15T20:57:00.001-08:00</published><updated>2011-12-12T21:08:12.181-08:00</updated><title type='text'>Working (around) with MSpecs</title><content type='html'>I just started playing with &lt;a href="https://github.com/machine/machine.specifications" target="_blank"&gt;Machine.Specifications&lt;/a&gt; (MSpecs). Overall I am very satisfied with the project but I did ran across some issues - dont get me wrong, it works great but it was more like limitations because I was lame and using Express edition.&lt;br /&gt;My specs are simple - I am trying to create a Dependency Injection Container that does absolutely very little, not as powerful as Unity or any other containers. I dont plan to use it anywhere - just am trying to create one for fun. So the specifications are simple (for now).&lt;br /&gt;&lt;pre class="xml" name="code"&gt; &lt;br /&gt;Mapping Interface to Type, MappingInterfaceToType&lt;br /&gt;  » should allow creating instance of type registered&lt;br /&gt;  &lt;br /&gt;  In case of multiple constructors, pick the one with injection attribute, MultipleConstructorScenario&lt;br /&gt;  » should create instance whose Value property is 20&lt;br /&gt;  &lt;br /&gt;  Container should support singleton instances, SingletonScenario&lt;br /&gt;  » should return the same instance for every invocation&lt;br /&gt;  &lt;br /&gt;  Inner container should be supported, SupportForInnerContainer&lt;br /&gt;  » should return registration from parent and itself&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Simple right? Those are the output for my specifications. It it still under works but the output itself explains a lot - thats the power of the MSpecs. Business Analysts write requirements, gives specifications - This can be changed - they give us the requirements and we "program" the specifications. I know it appears to be some rewired Unit Testing, but if unit tests can give me a bunch of specifications and tell me what failed, I would be more than happy to use that. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Now lets write a specification from scratch. Look at the following simple C# code. &lt;br /&gt;&lt;pre class="csharp" name="code"&gt; public class Singleton { }&lt;br /&gt;        public class Transient&lt;br /&gt;        {&lt;br /&gt;            public Singleton SingletonInstance { get; private set; }&lt;br /&gt;            public Transient(Singleton ins)&lt;br /&gt;            {&lt;br /&gt;                SingletonInstance = ins;&lt;br /&gt;            }&lt;br /&gt;        }&lt;/pre&gt;&lt;br /&gt;I would like to register the Singleton class as - singleton and the transient class as - transient. So my specification is, &lt;strong&gt;instances of transient whose dependency is a singleton should get the same instance. &lt;/strong&gt;So that becomes my "Subject" &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="csharp" name="code"&gt;[Subject("instances of transient whose dependency is a singleton should get the same instance.")]&lt;br /&gt;public class InjectionOfSingletonForTransientResolution&lt;br /&gt;{&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;Now to verify that specification, I need to &lt;strong&gt;"establish a context"&lt;/strong&gt; which is that I need my container to be ready for use.&lt;br /&gt;&lt;pre class="csharp" name="code"&gt; Establish context = () =&amp;gt;&lt;br /&gt; {&lt;br /&gt;            _builder = new TypeBuilder();&lt;br /&gt; };&lt;/pre&gt;&lt;br /&gt;Now that context is established, I will just write my specification. I create two instances and both my instances should have the same instance of Singleton. &lt;br /&gt;&lt;pre class="csharp" name="code"&gt;&lt;br /&gt;It Should_Use_The_Same_Instance_when_creating_dependent_Components = () =&gt;&lt;br /&gt;{&lt;br /&gt;            var instance1 = _builder.Resolve&lt;transient&gt;();&lt;br /&gt;            var instance2 = _builder.Resolve&lt;transient&gt;();&lt;br /&gt;            instance1.ShouldNotEqual(instance2);&lt;br /&gt;            instance1.SingletonInstance.ShouldNotBeNull();&lt;br /&gt;            instance2.SingletonInstance.ShouldNotBeNull();&lt;br /&gt;            instance1.SingletonInstance.ShouldEqual(instance2.SingletonInstance);&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;But you know this would not happen just like that. I have my context and I know what it should do. I need to tell it why it should do that - that specification would pass &lt;strong&gt;"because I am registering dependency as singleton and instance as transient".&lt;/strong&gt; So I add my reasons on why (or when) the specification would pass.&lt;br /&gt;&lt;pre class="csharp" name="code"&gt;&lt;br /&gt;Because I_Am_Making_A_Dependency_Registration_As_Singleton_And_TestSubject_As_Transient = () =&gt;&lt;br /&gt;{&lt;br /&gt;            _builder.Register&lt;singleton&gt;(new Singleton());&lt;br /&gt;            _builder.Register&lt;transient&gt;();&lt;br /&gt;};&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The whole specification would look like shown below. &lt;br /&gt;&lt;pre class="csharp" name="code"&gt;[Subject("instances of transient whose dependency is a singleton should get the same instance.")]&lt;br /&gt;    public class InjectionOfSingletonForTransientResolution&lt;br /&gt;    {&lt;br /&gt;        static ITypeBuilder _builder;&lt;br /&gt;&lt;br /&gt;        public class Singleton { }&lt;br /&gt;        public class Transient&lt;br /&gt;        {&lt;br /&gt;            public Singleton SingletonInstance { get; private set; }&lt;br /&gt;            public Transient(Singleton ins)&lt;br /&gt;            {&lt;br /&gt;                SingletonInstance = ins;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        Establish context = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder = new TypeBuilder();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        Because I_Am_Making_A_Dependency_Registration_As_Singleton_And_TestSubject_As_Transient = &lt;br /&gt;        () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder.Register&lt;singleton&gt;(new Singleton());&lt;br /&gt;            _builder.Register&lt;transient&gt;();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        It Should_Use_The_Same_Instance_when_creating_dependent_Components = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            var instance1 = _builder.Resolve&lt;transient&gt;();&lt;br /&gt;            var instance2 = _builder.Resolve&lt;transient&gt;();&lt;br /&gt;            instance1.ShouldNotEqual(instance2);&lt;br /&gt;            instance1.SingletonInstance.ShouldNotBeNull();&lt;br /&gt;            instance2.SingletonInstance.ShouldNotBeNull();&lt;br /&gt;            instance1.SingletonInstance.ShouldEqual(instance2.SingletonInstance);&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When I first run this my specification failed because my container does not handle that yet. &lt;br /&gt;&lt;pre class="xml" name="code"&gt; instances of transient whose dependency is a singleton should get the same instance., InjectionOfSingletonForTransientResolution&lt;br /&gt;  » Should Use The Same Instance when creating dependent Components (FAIL)&lt;br /&gt;  Machine.Specifications.SpecificationException: Should be [not null] but is [null]&lt;br /&gt;     at Machine.Specifications.ShouldExtensionMethods.ShouldNotBeNull(Object anObject) in d:\BuildAgent-03\work\38fe83de684fd902\Source\Machine.Specifications\ExtensionMethods.cs:line 181&lt;br /&gt;     at Analytics.Specifications.Container.InjectionOfSingletonForTransientResolution.&amp;lt;.ctor&amp;gt;b__2() in C:\Users\bhargav\documents\visual studio 2010\Projects\Analytics\Analytics.Specifications\Container\TypeBuilderSpecs.cs:line 159&lt;br /&gt;     at Machine.Specifications.Model.Specification.InvokeSpecificationField() in d:\BuildAgent-03\work\38fe83de684fd902\Source\Machine.Specifications\Model\Specification.cs:line 75&lt;br /&gt;     at Machine.Specifications.Model.Specification.Verify() in d:\BuildAgent-03\work\38fe83de684fd902\Source\Machine.Specifications\Model\Specification.cs:line 53&lt;/pre&gt;&lt;br /&gt;I fix my container and now I see my specification pass.&lt;br /&gt;&lt;br /&gt;One thing to remember is what ever you are working off - your context - it should be static - otherwise the compilation would fail. when looking at others examples, I had a similar question - so here I am telling you upfront.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Running specifications without leaving Visual Studio - No test runners are required.&lt;/h3&gt;&lt;br /&gt;All my specifications are in a separate class library. I would like to run the specifications without leaving Visual Studio (btw, I am using Express). I remember once upon a time I could make a class library as a startup project and somehow linked NUnit gui runner with the project. I could not get it done with VC# 2010 Express anymore. May be I am missing something. Anyway the solution was to add the following Post-Build event&lt;br /&gt;&lt;br /&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/TTJ6ruuy-ZI/AAAAAAAABbY/4OD3cJB2Sns/s1600-h/image%5B3%5D.png"&gt;&lt;img alt="image" border="0" height="277" src="http://lh5.ggpht.com/_Oy9HuksgrdU/TTJ6sZXdyjI/AAAAAAAABbc/PhFKCTD1BB0/image_thumb%5B1%5D.png?imgmax=800" style="background-image: none; border-bottom-width: 0px; border-left-width: 0px; border-right-width: 0px; border-top-width: 0px; display: inline; padding-left: 0px; padding-right: 0px; padding-top: 0px;" title="image" width="644" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once my specifications project it built successfully, it automatically generates a nice output. You can use all command line arguments that mspec supports, for now I only care if they pass or fail, hence the simple one.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Debugging my specifications. It was painful&lt;/h3&gt;&lt;br /&gt;I tried all different strategies like using System.Diagnostics.Debugger.Break() and what not. ConsoleRunner that comes with mspec (mspec.exe) was crashing complaining that it encountered an user defined breakpoint in the code - yeah that was my intention. Anyway to work around that, I create a console program and in the console application, I added reference to my specifications library and from the Git Hub source code for the mspec.exe (thanks to OSS) the following C# code helped me overcome my limitation of not being able to use R# or TestDriven.Net.&lt;br /&gt;&lt;pre class="csharp" name="code"&gt; class ContainerSpecsRunner&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            //Console.WriteLine(typeof(ITest).Assembly.Location);&lt;br /&gt;            Program prog = new Program(new DefaultConsole());&lt;br /&gt;            prog.Run(new[] { typeof(ITest).Assembly.Location });&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;ITest is a type that was defined in my specifications assembly. That way I need not worry about any arguments or hardcode path of my assembly. By the way, at work you might be killed for doing this, I am just doing it at my personal projects.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Some samples? &lt;/h3&gt;&lt;br /&gt;Ok the biggest problem I had was that I could not find some real world examples, the GIT HUB structure of the project was confusing as hell. I was hoping to find some examples, but I could not. As much as I like the project, I hate to see so little or almost non-existent guidance for new users. So here are some of my specifications. These are written by me - I am just learning the style of specs so forgive me if they are not what you wanted them to be. I am just trying to help. &lt;br /&gt;&lt;pre class="csharp" name="code"&gt;public interface ITest{&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public class Test: ITest{&lt;br /&gt;        [Injector]&lt;br /&gt;        public Test()&lt;br /&gt;        {&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [Subject("Mapping Interface to Type")]&lt;br /&gt;    public class MappingInterfaceToType&lt;br /&gt;    {&lt;br /&gt;        static ITypeBuilder _builder;&lt;br /&gt;&lt;br /&gt;        Establish context = () =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;            _builder = new TypeBuilder();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        Because of = () =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;            _builder.Register&lt;itest ,="" test=""&gt;();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        It should_allow_creating_instance_of_type_registered = () =&amp;gt;&lt;br /&gt;        {&lt;br /&gt;            var resolvedObject = _builder.Resolve&lt;itest&gt;();&lt;br /&gt;            resolvedObject.ShouldNotBeNull();&lt;br /&gt;            typeof(Test).ShouldEqual(resolvedObject.GetType()); &lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [Subject("In case of multiple constructors, pick the one with injection attribute")]&lt;br /&gt;    public class MultipleConstructorScenario&lt;br /&gt;    {&lt;br /&gt;        public class Test2 : ITest&lt;br /&gt;        {&lt;br /&gt;            public int Value { get; private set; }&lt;br /&gt;            public Test2(ITest demo)&lt;br /&gt;            {&lt;br /&gt;                Value = 10;&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            [Injector]&lt;br /&gt;            public Test2()&lt;br /&gt;            {&lt;br /&gt;                Value = 20;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        static ITypeBuilder _builder;&lt;br /&gt;        Establish context = () =&gt; {&lt;br /&gt;            _builder = new TypeBuilder();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        Because of = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder.Register&lt;ITest,Test2&gt;();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        It should_create_instance_whose_Value_property_is_20 = ()=&gt;&lt;br /&gt;{&lt;br /&gt;            var instance = _builder.Resolve&lt;ITest&gt;();&lt;br /&gt;            instance.ShouldBeOfType&lt;Test2&gt;();&lt;br /&gt;            (instance as Test2).Value.ShouldEqual(20);&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [Subject("Container should support singleton instances")]&lt;br /&gt;    public class SingletonScenario&lt;br /&gt;    {&lt;br /&gt;        static ITypeBuilder _builder;&lt;br /&gt;&lt;br /&gt;        Establish context = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder = new TypeBuilder();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        Because instance_Is_Registered = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder.Register&lt;ITest&gt;(()=&gt;new Test());&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        It should_return_the_same_instance_for_every_invocation = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder.Resolve&lt;ITest&gt;().ShouldEqual(_builder.Resolve&lt;ITest&gt;());&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    [Subject("Inner container should be supported")]&lt;br /&gt;    public class SupportForInnerContainer&lt;br /&gt;    {&lt;br /&gt;        static ITypeBuilder _builder;&lt;br /&gt;        static ITypeBuilder _child;&lt;br /&gt;        Establish context = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder = new TypeBuilder();&lt;br /&gt;            _child = _builder.CreateChildBuilder();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        Because instance_is_registered_with_child_container = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            _builder.Register&lt;IEnumerable&gt;(new int[] { 0, 1, 2 });&lt;br /&gt;            _child.Register&lt;ITest,Test2&gt;();&lt;br /&gt;        };&lt;br /&gt;&lt;br /&gt;        It should_return_registration_from_parent_and_itself = () =&gt;&lt;br /&gt;        {&lt;br /&gt;            var arr = (int[])_child.Resolve&lt;IEnumerable&gt;();&lt;br /&gt;            arr.SequenceEqual(new[] { 0, 1, 2 }).ShouldBeTrue();&lt;br /&gt;            _child.Resolve&lt;ITest&gt;().ShouldBeOfType&lt;Test&gt;();&lt;br /&gt;        };&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Would be nice if it can print my "Because" field names&lt;/h3&gt;&lt;br /&gt;Just like the console runner prints my "It" fields, it would be nicer if my reasons are printed. I will see if i can do that myself to the project and may contribute a little.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I hope the examples are useful. By no means they are perfect but they can get you started. You can see in the example I detailed in the beginning, I had a whole bunch of Should statements = that is plain wrong. Each specification should define one thing - otherwise it would be a big mess. Please look at this great project and I really am in love with MSpec.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-5422809560741155791?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/5422809560741155791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=5422809560741155791' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5422809560741155791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5422809560741155791'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2011/01/working-around-with-mspecs.html' title='Working (around) with MSpecs'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_Oy9HuksgrdU/TTJ6sZXdyjI/AAAAAAAABbc/PhFKCTD1BB0/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1993820527666761556</id><published>2011-01-13T19:39:00.001-08:00</published><updated>2011-01-13T19:42:18.265-08:00</updated><title type='text'>Executing RoutedCommand in Code-Behind</title><content type='html'>&lt;p&gt;Recently I had this issue where we had a bunch of routed commands but those which were to be bound to an event instead of directly on a Button.Command. Anyway with all the event to command redirection (hint: use System.Windows.Interactivity EventTriggers and TriggerAction&amp;lt;FrameworkElement&amp;gt;), the requirement boiled down to executing a RoutedCommand in code behind.&lt;/p&gt; &lt;p&gt;Consider the command had a base class which looks as shown below.&lt;/p&gt;&lt;pre class="csharp" name="code"&gt;public abstract class CommandBase&lt;br /&gt;    {&lt;br /&gt;        public ICommand Command { get; private set; }&lt;br /&gt;        public CommandBinding CommandBinding { get; private set; }&lt;br /&gt;        public CommandBase()&lt;br /&gt;        {&lt;br /&gt;            Command = new RoutedCommand();&lt;br /&gt;            CommandBinding = new CommandBinding(Command, HandlerExecute, HandlerCanExecute);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void HandlerExecute(object sender, ExecutedRoutedEventArgs args)&lt;br /&gt;        {&lt;br /&gt;            Execute(args.Parameter);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void HandlerCanExecute(object sender, CanExecuteRoutedEventArgs args)&lt;br /&gt;        {&lt;br /&gt;            args.CanExecute = CanExecute(args.Parameter);&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected abstract void Execute(object parameter);&lt;br /&gt;&lt;br /&gt;        protected abstract bool CanExecute(object parameter);&lt;br /&gt;&lt;br /&gt;        public static void DoCommandBind(CommandBase command, FrameworkElement element)&lt;br /&gt;        {&lt;br /&gt;            element.CommandBindings.Add(command.CommandBinding);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt; The base class simply provides everything that you need to make use of RoutedCommand. It wraps the command and its command binding whose execute and can execute handlers are redirected to the abstract methods. So the implementation would be as simple as the one shown below and you would have a full fledged RoutedCommand&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;public class SampleCommand : CommandBase&lt;br /&gt;    {&lt;br /&gt;        protected override void Execute(object parameter)&lt;br /&gt;        {&lt;br /&gt;            MessageBox.Show(parameter.ToString());&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        protected override bool CanExecute(object parameter)&lt;br /&gt;        {&lt;br /&gt;            return parameter != null;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;In the above command, I simply execute the command if there is a parameter sent and when executed display the parameter passed in a MessageBox. In order to use this command in XAML, the markup would be as simple as : &lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;Button Command="{Binding Sample.Command}" CommandParameter="This is from XAML" Content="From XAML" /&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;But for the RoutedCommand to work, the CommandBinding associated with it should be added to one of the elements up in the Visual Tree. So one of the parents for the Button should have the CommandBinding for the command to be registered with them. This is performed using the CommandBase.DoCommandBind() method. This is required because - the RoutedCommand - even though it implements ICommand interface, the Execute() and CanExecute() methods simply trigger the events that result in the CommandBinding execute the handlers that were specified when the command binding was being created. Read on MSDN for a much better english explanation. If the command binding cannot be found on any of the ancestors, the command would never fire! This is important to understand when we later look at the C# way to execute a RoutedCommand. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; For now, look at the code behind. It is simple and what happens in the constructor is self explanatory. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;        private CommandBase sample = new SampleCommand();&lt;br /&gt;        &lt;br /&gt;        public CommandBase Sample&lt;br /&gt;        {&lt;br /&gt;            get { return sample; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public CommandDemo()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            this.DataContext = this;&lt;br /&gt;	    //do a command binding on this UserControl itself.&lt;br /&gt;            CommandBase.DoCommandBind(sample, this);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Gotcha 1 : RoutedCommand does not fire!&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;If this is the case, then make sure the CommandBinding for the RoutedCommand has been registered properly. You can do it in Code-Behind (like CommandBase.DoCommandBind() in my example) or in XAML (loads of examples online for that).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt; How do I execute a RoutedCommand from code-behind? &lt;/h3&gt;&lt;br /&gt;&lt;p&gt; Again, same rules apply. The command binding should be available to be found on the ancestors where the command will be fired. If that is the case, then you can do it in the following way.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;var rc = (sample.Command as RoutedCommand);&lt;br /&gt;if (rc.CanExecute("This is command parameter", e.OriginalSource as Control))&lt;br /&gt;   rc.Execute("This is command parameter", e.OriginalSource as Control);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;P&gt; Executing the ICommand.Execute(parameter) (eg: sample.Command.Execute("parameter")) would work, but if in any case it does not work, use the method above. &lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Gotcha 2 : RoutedCommand.CanExecute(parameter) does not fire when executing a RoutedCommand from code-behind!&lt;/h3&gt;&lt;br /&gt;&lt;p&gt; Yes, ICommand.CanExecute() is just an interface method, its the job the command invoker (if done in code-behind, it is you who is the command invoker) to verify if the command can be executed using CanExecute(). &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; Well, thats all for now, I hope this helps some of us who were struggling with one place solution to execute RoutedCommands in code-behind. Hopefully, I will write  one more brief article on using System.Windows.Interactivity.Triggers to redirect an event to a command, the MVVM way of executing actions. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1993820527666761556?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1993820527666761556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1993820527666761556' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1993820527666761556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1993820527666761556'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2011/01/executing-routedcommand-in-code-behind.html' title='Executing RoutedCommand in Code-Behind'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1598512854142598491</id><published>2010-07-19T21:08:00.001-07:00</published><updated>2010-07-19T21:08:04.105-07:00</updated><title type='text'>Bing! Are you kidding me!</title><content type='html'>&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/TEUhHzpxbrI/AAAAAAAABaM/JVYQ5b43lN0/s1600-h/image%5B3%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/TEUhInM_e2I/AAAAAAAABaQ/eBb6TyGHYJU/image_thumb%5B1%5D.png?imgmax=800" width="644" height="440"&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Seriously?? If these things happen, Bing! would never be the search engine that I wish it would become.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1598512854142598491?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1598512854142598491/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1598512854142598491' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1598512854142598491'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1598512854142598491'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/07/bing-are-you-kidding-me.html' title='Bing! Are you kidding me!'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/TEUhInM_e2I/AAAAAAAABaQ/eBb6TyGHYJU/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-2683795173435651148</id><published>2010-07-16T15:05:00.001-07:00</published><updated>2010-07-16T15:05:36.989-07:00</updated><title type='text'>WPF Datagrid – Load and Performance</title><content type='html'>&lt;p&gt;This post is not about performance numbers of WPF Datagrid but simply about what you should be aware of in order to make it perform well. I was not motivated enough to use profiler to show realistic numbers but instead used the Stopwatch class wherever applicable. This post does not go into techniques to handle large amounts of data such as Paging or how to implement paging, but focuses on how to make the datagrid work with large data.&lt;/p&gt; &lt;p&gt;Here is the C# class that generates the data I want to load the Datagrid with.&lt;/p&gt;&lt;pre class="csharp" name="code"&gt;public class DataItem&lt;br /&gt;    {&lt;br /&gt;        public long Id { get; set; }&lt;br /&gt;        public string FirstName { get; set; }&lt;br /&gt;        public string LastName { get; set; }&lt;br /&gt;        public long Age { get; set; }&lt;br /&gt;        public string City { get; set; }&lt;br /&gt;        public string Designation { get; set; }&lt;br /&gt;        public string Department { get; set; }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;    public static class DataGenerator&lt;br /&gt;    {&lt;br /&gt;        private static int _next = 1;&lt;br /&gt;        public static IEnumerable&lt;dataitem&gt; GetData(int count)&lt;br /&gt;        {&lt;br /&gt;            for (var i = 0; i &amp;lt; count; i++)&lt;br /&gt;            {&lt;br /&gt;                string nextRandomString = NextRandomString(30);&lt;br /&gt;                yield return new DataItem&lt;br /&gt;                                 {&lt;br /&gt;                                     Age = rand.Next(100),&lt;br /&gt;                                     City = nextRandomString,&lt;br /&gt;                                     Department = nextRandomString,&lt;br /&gt;                                     Designation = nextRandomString,&lt;br /&gt;                                     FirstName = nextRandomString,&lt;br /&gt;                                     LastName = nextRandomString,&lt;br /&gt;                                     Id = _next++&lt;br /&gt;                                 };&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private static readonly Random rand = new Random();&lt;br /&gt;&lt;br /&gt;        private static string NextRandomString(int size)&lt;br /&gt;        {&lt;br /&gt;            var bytes = new byte[size];&lt;br /&gt;            rand.NextBytes(bytes);&lt;br /&gt;            return Encoding.UTF8.GetString(bytes);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;My ViewModel has been defined as shown below.&lt;/p&gt;&lt;pre class="csharp" name="code"&gt; public class MainWindowViewModel : INotifyPropertyChanged&lt;br /&gt;    {&lt;br /&gt;        private void Notify(string propName)&lt;br /&gt;        {&lt;br /&gt;            if (PropertyChanged != null)&lt;br /&gt;                PropertyChanged(this, new PropertyChangedEventArgs(propName));&lt;br /&gt;        }&lt;br /&gt;        public event PropertyChangedEventHandler PropertyChanged;&lt;br /&gt;&lt;br /&gt;        private Dispatcher _current;&lt;br /&gt;        public MainWindowViewModel()&lt;br /&gt;        {&lt;br /&gt;            _current = Dispatcher.CurrentDispatcher;&lt;br /&gt;            DataSize = 50;&lt;br /&gt;            EnableGrid = true;&lt;br /&gt;            _data = new ObservableCollection&lt;dataitem&gt;();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private int _dataSize;&lt;br /&gt;        public int DataSize&lt;br /&gt;        {&lt;br /&gt;            get { return _dataSize; }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                LoadData(value - _dataSize);&lt;br /&gt;                _dataSize = value;&lt;br /&gt;                Notify("DataSize");&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private ObservableCollection&lt;dataitem&gt; _data;&lt;br /&gt;        public ObservableCollection&lt;dataitem&gt; Data&lt;br /&gt;        {&lt;br /&gt;            get { return _data; }&lt;br /&gt;            set&lt;br /&gt;            {&lt;br /&gt;                _data = value;&lt;br /&gt;                Notify("Data");&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private bool _enableGrid;&lt;br /&gt;        public bool EnableGrid&lt;br /&gt;        {&lt;br /&gt;            get { return _enableGrid; }&lt;br /&gt;            set { _enableGrid = value; Notify("EnableGrid"); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private void LoadData(int more)&lt;br /&gt;        {&lt;br /&gt;            Action act = () =&amp;gt;&lt;br /&gt;                             {&lt;br /&gt;                                 EnableGrid = false;&lt;br /&gt;                                 if (more &amp;gt; 0)&lt;br /&gt;                                 {&lt;br /&gt;                                     foreach (var item in DataGenerator.GetData(more))&lt;br /&gt;                                         _data.Add(item);&lt;br /&gt;                                 }&lt;br /&gt;                                 else&lt;br /&gt;                                 {&lt;br /&gt;                                     int itemsToRemove = -1 * more;&lt;br /&gt;                                     for (var i = 0; i &amp;lt; itemsToRemove; i++)&lt;br /&gt;                                         _data.RemoveAt(_data.Count - i - 1);&lt;br /&gt;                                 }&lt;br /&gt;                                 EnableGrid = true;&lt;br /&gt;                             };&lt;br /&gt;            //act.BeginInvoke(null, null);&lt;br /&gt;            _current.BeginInvoke(act, DispatcherPriority.ApplicationIdle);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;As you can see, as the DataSize is changed, the data would be loaded. Currently I use a slider to change the load size. This is all pretty easy and fun stuff starts in the XAML.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;In order to apply this "Data" to my WPF datagrid, I apply this viewmodel instance to the DataContext of my class. See below for the code-behind that I have for my window&lt;/p&gt;&lt;pre class="csharp" name="code"&gt; public partial class MainWindow : Window&lt;br /&gt;    {&lt;br /&gt;        private MainWindowViewModel vm;&lt;br /&gt;&lt;br /&gt;        public MainWindow()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            vm = new MainWindowViewModel();&lt;br /&gt;            this.Loaded += (s, e) =&amp;gt; DataContext = vm;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Lets start with the following XAML.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;stackpanel&amp;gt;&lt;br /&gt;	&amp;lt;slider maximum="100" minimum="50" value="{Binding DataSize}" /&amp;gt;&lt;br /&gt;        &amp;lt;label grid.row="1" content="{Binding DataSize}"&amp;gt;&lt;br /&gt;        &amp;lt;datagrid grid.row="2" isenabled="{Binding EnableGrid}" itemssource="{Binding Data}"&amp;gt;&lt;br /&gt;	&amp;lt;/datagrid&amp;gt;&lt;br /&gt;&amp;lt;/stackpanel&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Now build the application and run. The result appear as shown below. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/TEDXbtApboI/AAAAAAAABZc/3rdhYAAloCQ/s1600-h/image%5B3%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/TEDXdbsXOVI/AAAAAAAABZg/6v5-_uHi5bU/image_thumb%5B1%5D.png?imgmax=800" width="644" height="342"&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;As you can see above, I loaded 100 items yet &lt;strong&gt;I do not see the scrollbar.&lt;/strong&gt; Lets change the slider’s Maximum property from 100 to 1000 and rerun the application. Dragging the slider to 1000 at once. So even for the 1000 items, the grid does not respond that well. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/TEDXese1pQI/AAAAAAAABZk/Lf5WvtHpv-Y/s1600-h/image%5B7%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/TEDXgOGsWcI/AAAAAAAABZo/B66G-Pnfbj8/image_thumb%5B3%5D.png?imgmax=800" width="463" height="300"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Let us look at the memory usage.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/TEDXg-J5y0I/AAAAAAAABZs/qussD_l9bj4/s1600-h/image%5B13%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/TEDXiOXsUvI/AAAAAAAABZw/iU1PwM3QkSg/image_thumb%5B7%5D.png?imgmax=800" width="433" height="38"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;This is pretty heavy for an application with just 1000 items of data loaded. So what is using all this memory? You can hook up a Memory Profiler or use Windbg to look at the memory content but since I already know what is causing this issue, I am not going through that. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;This issue is that the DataGrid has been placed inside a StackPanel. When vertically stacked, the StackPanel basically gives its children all the space that they ask for. This makes the DataGrid create 1000 rows (all the UI elements needed for each column of each row !!) and render it. The virtualization of the DataGrid did not come into play here.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So let us make a simple change and put the DataGrid inside a grid. The XAML for which is shown below.&lt;/p&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;Grid&amp;gt;&lt;br /&gt;        &amp;lt;Grid.RowDefinitions&amp;gt;&lt;br /&gt;            &amp;lt;RowDefinition Height="30"/&amp;gt;&lt;br /&gt;            &amp;lt;RowDefinition Height="30"/&amp;gt;&lt;br /&gt;            &amp;lt;RowDefinition Height="*"/&amp;gt;&lt;br /&gt;        &amp;lt;/Grid.RowDefinitions&amp;gt;&lt;br /&gt;        &amp;lt;Slider Value="{Binding DataSize}" Minimum="50" Maximum="1000"/&amp;gt;&lt;br /&gt;        &amp;lt;Label Content="{Binding DataSize}" Grid.Row="1"/&amp;gt;&lt;br /&gt;        &amp;lt;DataGrid ItemsSource="{Binding Data}" Grid.Row="2" IsEnabled="{Binding EnableGrid}"&amp;gt;           &lt;br /&gt;        &amp;lt;/DataGrid&amp;gt;&lt;br /&gt;    &amp;lt;/Grid&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;When I run the application, you would notice that as I load 1000 items, the performance of the same application (no code changes, except that XAML one I just talked about) is a lot better than what it was. Moreover I see nice scrollbars.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/TEDXklUvTrI/AAAAAAAABZ0/QRDfmfugJvc/s1600-h/image%5B19%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/TEDXmBiLhWI/AAAAAAAABZ4/inpHNDHNOIY/image_thumb%5B11%5D.png?imgmax=800" width="644" height="342"&gt;&lt;/a&gt; &lt;br /&gt;&lt;p&gt;Let us look at the memory usage.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/TEDXmkYFIJI/AAAAAAAABZ8/2Eip9xZ103Q/s1600-h/image%5B23%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/TEDXn2IrfBI/AAAAAAAABaA/PxbE3KnIMJc/image_thumb%5B13%5D.png?imgmax=800" width="644" height="29"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Wow! 10 folds difference. This until now appears to be a re-talk about my &lt;a href="http://krishnabhargav.blogspot.com/2008/10/wpf-performance-ui-virtualization.html"&gt;previous post on WPF Virtualization&lt;/a&gt;. The same rules applies to DataGrid as well. Read this post if you are intertested.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So what else am I talking here. &lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;If you notice the ViewModel code, you should be seeing that I disable the grid as I load data and enable it back once I am done. I have not really tested to see if this technique helps, but I did use this technique in HTML pages where loads of items in a listbox were all to be selected and this technique was very useful. &lt;br /&gt;&lt;li&gt;In all the screenshots I showed, the grid is sorted. So as the data changes, the grid has to keep sorting the data and show based on what you chose to sort. This, I believe, is a big overhead. Consider removing sort of the datagrid before you change the data if it is a viable option and does not impact the end user. Have not tested this, but the same should apply to the groupings as well (which most of the time cannot be simply removed).&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;With a simple point of loading the DataGrid into any other panel like Grid, instead of a StackPanel you get to see a lot of difference. The WPF datagrid performs just fine, as long as you keep the viewable region of the grid small. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;Shown below is my grid with almost 1 Million data items loaded. The footprint is pretty small compared to the amount of data loaded. This means – either WPF Controls are memory intensive or WPF UI Virtualization is a boon.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Impact of sorting on the DataGrid&lt;/h3&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;With no sorting applied on the datagrid, it took almost 20 seconds to load 1 Million items into my collection. &lt;br /&gt;&lt;li&gt;With sorting enabled, loading half those items iteself took over 2 minutes and the complete items took over 5 minutes and I killed the application because it was a pain. This matters because the application keeps the CPU busy with all the sort that has to keep happening as your data changes. So for every item added, the sort might be triggered, since I am placing it directly into an observable collection. &lt;br /&gt;&lt;li&gt;&lt;strong&gt;Instead consider sorting on the backend and not using the datagrid.&lt;/strong&gt;&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/TEDXpTKw1aI/AAAAAAAABaE/MJT3rJfALlk/s1600-h/image%5B31%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/TEDXrgUUjsI/AAAAAAAABaI/yhRUGjP4-Cc/image_thumb%5B19%5D.png?imgmax=800" width="644" height="342"&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;I can still scroll the application if the virtualization was properly utilized, inspite of the grid binding to 1 million items&lt;strong&gt;.&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;USING BeginInit() and EndInit() on the datagrid.&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;I changed the ViewModel’s LoadData() such that it calls BeginInit() as it starts loading the data and EndInit() when it done loading the data. This has helped quite a lot. Loading 1 Million items (without any sort applied on the grid) only took around 8 seconds (compared to the 18 seconds it took earlier). &lt;strong&gt;Unfortunately I did not spend enough time to use a profiler to show real numbers.&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The changed code-behind for the Window is as shown.&lt;/p&gt;&lt;pre class="csharp" name="code"&gt;public partial class MainWindow : Window&lt;br /&gt;    {&lt;br /&gt;        private MainWindowViewModel vm;&lt;br /&gt;&lt;br /&gt;        public MainWindow()&lt;br /&gt;        {&lt;br /&gt;            InitializeComponent();&lt;br /&gt;            vm = new MainWindowViewModel();&lt;br /&gt;            this.Loaded += (s, e) =&amp;gt; DataContext = vm;&lt;br /&gt;            vm.DataChangeStarted += () =&amp;gt; dg.BeginInit();&lt;br /&gt;            vm.DataChangeCompleted += () =&amp;gt; dg.EndInit();&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;I also had to include the DataChangeStarted and DataChangeCompleted actions to the Viewmodel class. The changed portion of the ViewModel class is shown below.&lt;/p&gt;&lt;pre class="csharp" name="code"&gt;	public event Action DataChangeStarted ;&lt;br /&gt;        public event Action DataChangeCompleted;&lt;br /&gt;&lt;br /&gt;        private void LoadData(int more)&lt;br /&gt;        {&lt;br /&gt;            Action act = () =&amp;gt;&lt;br /&gt;                             {&lt;br /&gt;				 //Before the data starts change, call the method.&lt;br /&gt;                                 if (DataChangeStarted != null) DataChangeStarted();&lt;br /&gt;                                 var sw = Stopwatch.StartNew();&lt;br /&gt;                                 EnableGrid = false;&lt;br /&gt;                                 if (more &amp;gt; 0)&lt;br /&gt;                                 {&lt;br /&gt;                                     foreach (var item in DataGenerator.GetData(more))&lt;br /&gt;                                         _data.Add(item);&lt;br /&gt;                                 }&lt;br /&gt;                                 else&lt;br /&gt;                                 {&lt;br /&gt;                                     int itemsToRemove = -1 * more;&lt;br /&gt;                                     for (var i = 0; i &amp;lt; itemsToRemove; i++)&lt;br /&gt;                                         _data.RemoveAt(_data.Count - i - 1);&lt;br /&gt;                                 }&lt;br /&gt;                                 EnableGrid = true;&lt;br /&gt;                                 sw.Stop();&lt;br /&gt;                                 Debug.WriteLine(sw.ElapsedMilliseconds);&lt;br /&gt;                                 if (DataChangeCompleted != null) DataChangeCompleted();&lt;br /&gt;                             };&lt;br /&gt;            //act.BeginInvoke(null, null);&lt;br /&gt;            _current.BeginInvoke(act, DispatcherPriority.ApplicationIdle);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;You can try this out and notice the performance difference yourself. &lt;/p&gt;&lt;br /&gt;&lt;p&gt;If the sorting is applied on the datagrid, the performance still hurts in spite of using the above mentioned trick. The overhead of sorting out weighs the performance gain we get calling the BeginInit and EndInit. May be having 1 million records is not realistic enough. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-2683795173435651148?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/2683795173435651148/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=2683795173435651148' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/2683795173435651148'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/2683795173435651148'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/07/wpf-datagrid-load-and-performance.html' title='WPF Datagrid – Load and Performance'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_Oy9HuksgrdU/TEDXdbsXOVI/AAAAAAAABZg/6v5-_uHi5bU/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-8012136852546815692</id><published>2010-07-15T19:30:00.000-07:00</published><updated>2010-07-15T19:37:24.402-07:00</updated><title type='text'>Using LINQ Aggregate to solve the previous problem</title><content type='html'>In the &lt;a href="http://krishnabhargav.blogspot.com/2010/07/algorithms-performance-and-getting.html"&gt;previous post&lt;/a&gt; I talked about the problem which I simply re-iterate here. From the data which can look like &lt;p/&gt;&lt;br /&gt;Name, Value &lt;p/&gt;&lt;br /&gt;Sridhar, 1 &lt;p/&gt;&lt;br /&gt;Ashish,2&lt;p/&gt;&lt;br /&gt;PRasanth,3&lt;p/&gt;&lt;br /&gt;Ashish,5&lt;p/&gt;&lt;br /&gt;Sridhar,6&lt;p/&gt;&lt;br /&gt;Prasanth,34&lt;p/&gt;&lt;br /&gt;.....&lt;br /&gt;&lt;br /&gt;I want to aggregate the values for the names. Look at the previous post for some information on other approaches to solve this simple problem.&lt;br /&gt;&lt;br /&gt;The LINQ way to do this would be : &lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;[Test]&lt;br /&gt;        public void BTest()&lt;br /&gt;        {&lt;br /&gt;            var nvcs = tl.GroupBy(s =&gt; s.Name)&lt;br /&gt;                .Select(s =&gt; new NameValueCollection&lt;br /&gt;                                 {&lt;br /&gt;                                     {"Name", s.Key},&lt;br /&gt;                                     {"DrawerId", s.Aggregate(new StringBuilder(), &lt;br /&gt;                                        (seed, g) =&gt; seed.AppendFormat("{0};",g.DrawerId)).ToString()}&lt;br /&gt;                                 });&lt;br /&gt;            //foreach (var nvc in nvcs)&lt;br /&gt;            //    Console.WriteLine(nvc["Name"] + " : " + nvc["DrawerId"]);&lt;br /&gt;            Assert.AreEqual(4, nvcs.Count());&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Note that I wanted am generating a list of NameValueCollection and this is not of significance here. If you compare it with the previous implementation that uses dictionary or lists to generate, this solution appears more concise and to those who already knows LINQ should find this really simple.&lt;br /&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; All I would like to take away from this post is that the IEnumerable.Aggregate() method is a great method that is not often mentioned around. We often accumulate some value over a collection of items and aggregate method lets you do just that without all the extra for and seeds that you should track.&lt;br /&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-8012136852546815692?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/8012136852546815692/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=8012136852546815692' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8012136852546815692'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8012136852546815692'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/07/using-linq-aggregate-to-solve-previous.html' title='Using LINQ Aggregate to solve the previous problem'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1228578486524963814</id><published>2010-07-15T19:05:00.000-07:00</published><updated>2010-07-15T19:38:36.659-07:00</updated><title type='text'>Algorithms, performance and getting burnt</title><content type='html'>After a long time, I am writing something on my blog. So here it is ..&lt;p&gt;This post is about me starting to solve a small but interesting problem with different approaches and ended up breaking my head against why an algorithm with supposedly O(n) complexity is 4 times slower than O(n^2).&lt;/p&gt;&lt;p&gt;So here's the issue. I have the following data : &lt;/p&gt;&lt;p&gt;Name,Value &lt;p/&gt;&lt;br /&gt;Sridhar,1&lt;p/&gt;&lt;br /&gt;Ashish,2&lt;p/&gt;&lt;br /&gt;Prasanth,3&lt;p/&gt;&lt;br /&gt;Sridhar,4&lt;p/&gt;&lt;br /&gt;Ashish,5&lt;p/&gt;&lt;br /&gt;Sridhar,8&lt;/p&gt;&lt;p&gt;and so on .. I hope you get the idea.&lt;br /&gt;&lt;br /&gt;Now what I would like to do is to print the following output.&lt;p/&gt;&lt;br /&gt;Sridhar : 1;4;8;....&lt;p/&gt;&lt;br /&gt;Ashish : 2;4;.....&lt;p/&gt;&lt;br /&gt;Prasanth: 3;......&lt;p/&gt;&lt;br /&gt;&lt;br /&gt;Note that here, it does not matter what the values are, I am giving this data just for the example. So shown below is my setup which would be used by my implementations. (I am demoing it as a test).&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;  private Stopwatch sw;&lt;br /&gt;        [SetUp]&lt;br /&gt;        public void SetUp()&lt;br /&gt;        {&lt;br /&gt;            GC.GetTotalMemory(true); // I dont know why i did this!&lt;br /&gt;            tl = new List&lt;Ud&gt;(10000);&lt;br /&gt;            var names = new[] { "Krishna", "Ashish", "Sridhar", "Prasanth" };&lt;br /&gt;            foreach (var name in names)&lt;br /&gt;                for (var i = 0; i &lt; 2500; i++)&lt;br /&gt;                    tl.Add(new Ud { Name = name, DrawerId = i.ToString() });&lt;br /&gt;            tl.OrderBy(s =&gt; s.DrawerId);&lt;br /&gt;            sw = Stopwatch.StartNew();&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        [TearDown]&lt;br /&gt;        public void TearDown()&lt;br /&gt;        {&lt;br /&gt;            sw.Stop();&lt;br /&gt;            Console.WriteLine(sw.ElapsedMilliseconds);&lt;br /&gt;            sw = null;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public class Ud&lt;br /&gt;        {&lt;br /&gt;            public string Name { get; set; }&lt;br /&gt;            public string DrawerId { get; set; }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private List&lt;Ud&gt; tl;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;The above code is self explanatory. I basically create a lot of Ud objects which generate the data that I presented earlier. Shown below is the most straight forward way to do it. It has two for-loops which makes the complexity O(n^2).&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;[Test]&lt;br /&gt;        public void BasicImplementation()&lt;br /&gt;        {&lt;br /&gt;            var nvcs = new List&lt;NameValueCollection&gt;();&lt;br /&gt;            var list = new List&lt;string&gt;();&lt;br /&gt;            foreach (var item in tl)&lt;br /&gt;            {&lt;br /&gt;                if (list.Contains(item.Name)) continue;&lt;br /&gt;&lt;br /&gt;                string val = string.Empty;&lt;br /&gt;&lt;br /&gt;                foreach (var item2 in tl)&lt;br /&gt;                {&lt;br /&gt;                    if (item2.Name == item.Name)&lt;br /&gt;                        val += item2.DrawerId + ";";&lt;br /&gt;                }&lt;br /&gt;&lt;br /&gt;                nvcs.Add(new NameValueCollection { { "Name", item.Name }, { "DrawerId", val } });&lt;br /&gt;                list.Add(item.Name);&lt;br /&gt;            }&lt;br /&gt;            //foreach (var nvc in nvcs)&lt;br /&gt;            //    Console.WriteLine(nvc["Name"] + " : " + nvc["DrawerId"]);&lt;br /&gt;            Assert.AreEqual(4, nvcs.Count);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt; Now I went ahead and added another potential implementation which gives the same result but instead makes use of dictionary to track the strings that we build for each name in the list of objects. So instinctively, it appears that the dictionary method would be way faster than the one mentioned above. Lets look at that code. &lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;        [Test]&lt;br /&gt;        public void ADictionary()&lt;br /&gt;        {&lt;br /&gt;            var vals = new Dictionary&lt;string, string&gt;();&lt;br /&gt;            foreach (var item in tl)&lt;br /&gt;            {&lt;br /&gt;                if (!vals.ContainsKey(item.Name))&lt;br /&gt;                    vals[item.Name] = item.DrawerId;&lt;br /&gt;                else&lt;br /&gt;                    vals[item.Name] = vals[item.Name] + item.DrawerId + ";";&lt;br /&gt;            }&lt;br /&gt;            Assert.AreEqual(4, vals.Values.Count);&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt; When I ran these two tests, I did not notice any performance gain with the above O(n) implementation and in fact it was three times slower. So why was it slower? Look at the setup, it has GC.GetTotalMemory(true) which forced a full garbage collection and its time was accounted in the time consumed by this dictionary as well since for the second time (when test with dictionary was executing) it had a lot of strings to clean up. So why did I put it in the first place? The answer is "I was not thinking straight". Never ever use GC classes in your code. It is a bad-bad-bad practice.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So I remove this GC call made and rerun the tests again. Yet I do not see any performance gain. WHY?? I took a lot of time trying to diagnose why this is happening and eventually gave up manual inspection. I downloaded the trail version of dotTrace (which is freaking awesome tool) Performance 4.0 and made it profile both the tests. The culprit was the strings. If you look at the code right, we are generate a lot of strings whose "Concat" operation was so time consuming that it dominated the gain that we obtained using O(n) algorithm.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;So the lesson here is "Be watchful of the strings that are generated when your code executes, otherwise you would be burned". It does not matter how small the string concatenation may seem but in cases like above it piles up a lot and screws up your clever algorithm. All I did was to change the tests to use stringbuilder instead of Strings.&lt;/p&gt; &lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; Do not use GC calls in your code, especially those which force GC.&lt;br /&gt;&lt;li&gt; Use a profiler to accurately capture performance information of specific methods or your program. Stopwatch, Timers, etc are not good enough and waste of time.&lt;br /&gt;&lt;li&gt; Be aware of the impact of string operations. Use StringBuilder wherever possible. Use String.Format() in other simpler cases.&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;I will continue in the next post with some code that shows you how to approach the problem I initially started with using LINQ and how simple things would appear.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1228578486524963814?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1228578486524963814/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1228578486524963814' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1228578486524963814'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1228578486524963814'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/07/algorithms-performance-and-getting.html' title='Algorithms, performance and getting burnt'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-8642734044419884089</id><published>2010-07-11T21:00:00.000-07:00</published><updated>2010-07-11T21:01:16.020-07:00</updated><title type='text'>Issues with SyntaxHighlighter on my blog</title><content type='html'>I just messed up my blog template and could not get the syntaxhighlighter plugin to work properly. I will be fixing this shortly but in the meantime if the code seems really ugly to you all, I apologize for the inconvenience.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-8642734044419884089?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/8642734044419884089/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=8642734044419884089' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8642734044419884089'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8642734044419884089'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/07/issues-with-syntaxhighlighter-on-my.html' title='Issues with SyntaxHighlighter on my blog'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-6532311396829523790</id><published>2010-05-05T21:24:00.001-07:00</published><updated>2010-07-11T21:47:56.355-07:00</updated><title type='text'>WCF Security – the way I wanted to learn</title><content type='html'>&lt;p&gt;For intranet applications where the users could be authenticated against Active Directory, using WindowsCredentials, setting up security for a WCF service might not be all that difficult. It might not be difficult even to set up a WCF Service hosted by IIS and make it use the ASP.NET Roles/Providers. But what I wanted was to come up with a series of steps that allows me to secure a WCF service for internet-like applications. While it appears that there would have been 1000s of implementations on the subject where the client application provides a UserName/Password login control and then on the authenticated users would be able to work with the service.&lt;/p&gt;  &lt;p&gt;To go back a little, this is what I want &lt;/p&gt;  &lt;p&gt;-&amp;#160; I have a client application which has a Login Control and the user enters Username and password. Without proper username.password combination, the service communications going forward should not be allowed. Remember Forms Authentication in ASP.NET ?? Something similar to that. &lt;/p&gt;  &lt;p&gt;- I do not want to tie my service strongly to the host – meaning I do not want to make use of the ASP.NET Membership Provider models, though it is relatively easy to do so. So I have a console host program that serves as the WCF Service.&lt;/p&gt;  &lt;p&gt;- For every call to an OperationContract, I do not want to read the Message Headers or add extra parameters to see the username and password. I don’t want specific logic within each operation that handles this check.&lt;/p&gt;  &lt;p&gt;- I want the operations to be limited to those users with some kind of “Roles”. Basically, i have a set of operations that only users of a Role “X” should be able to perform; whereas there are some other operations for users with other roles.&lt;/p&gt;  &lt;p&gt;- I don’t want my communication channel to be open and would want to prevent the users to sniff the traffic to see what is going on.&lt;/p&gt;  &lt;p&gt;To summarize these requirements, &lt;/p&gt;  &lt;p&gt;- I want a secure communication between client and server.   &lt;br /&gt;- I want to restrict access to the service unless the client sends in valid username/password.    &lt;br /&gt;- I want to restrict access to operations based on the roles of the calling user.    &lt;br /&gt;- I don’t want to deal with Windows Authentication at this moment, since I have plans to host my service on the internet in which case WindowsIdentity is not really preferred.&lt;/p&gt;  &lt;p&gt;In this post, I would like to show the way I achieved these goals. Note that I am not qualified enough to make strong statements or give strong explanation on how the security works. The intention of this post would be to help assist developers like me who has little knowledge of WCF Security but do understand how Security works in general. I recommend you read MSDN documentation for the classes and terms I throw here and there.&lt;/p&gt;  &lt;p&gt;While, the source code is available for download here : &lt;a href="http://drop.io/yskic3h"&gt;http://drop.io/yskic3h&lt;/a&gt; , here in this post I simply mention the steps that I used to achieve each of the goals mentioned above.&lt;/p&gt;  &lt;h3&gt;1. Secure Communication Channel&lt;/h3&gt;  &lt;p&gt;Used wsHttpBinding as the binding of my choice. The wsHttpBinding by default employs Windows security. We would have to change that to make use of Message security using “UserName” as clientCredentialType. All this is configured as a binding configuration.&lt;/p&gt;  &lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;wsHttpBinding&amp;gt;&lt;br /&gt;	&amp;lt;binding name=&amp;quot;secureBinding&amp;quot;&amp;gt;&lt;br /&gt;		&amp;lt;!-- the security would be applied at Message level --&amp;gt;&lt;br /&gt;			&amp;lt;security mode=&amp;quot;Message&amp;quot;&amp;gt;&lt;br /&gt;				&amp;lt;message clientCredentialType=&amp;quot;UserName&amp;quot;/&amp;gt;&lt;br /&gt;			&amp;lt;/security&amp;gt;&lt;br /&gt;	&amp;lt;/binding&amp;gt;&lt;br /&gt;&amp;lt;/wsHttpBinding&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;Now this bindingConfiguration has to be set on the endpoint as shown&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;services&amp;gt;&lt;br /&gt;      &amp;lt;service name=&amp;quot;WcfService.SecureService&amp;quot; behaviorConfiguration=&amp;quot;secureBehavior&amp;quot;&amp;gt;&lt;br /&gt;				&amp;lt;!-- &lt;br /&gt;				notice the bindingConfiguration, we are applying secureBinding that&lt;br /&gt;				was defined in the bindings section.&lt;br /&gt;				--&amp;gt;&lt;br /&gt;				&amp;lt;endpoint address=&amp;quot;secureService&amp;quot;&lt;br /&gt;						  binding=&amp;quot;wsHttpBinding&amp;quot;						  &lt;br /&gt;						  bindingConfiguration=&amp;quot;secureBinding&amp;quot;&lt;br /&gt;						  contract=&amp;quot;WcfService.ISecureService&amp;quot;/&amp;gt;&lt;br /&gt;				&amp;lt;host&amp;gt;&lt;br /&gt;					&amp;lt;baseAddresses&amp;gt;&lt;br /&gt;						&amp;lt;add baseAddress=&amp;quot;http://truebuddi:8080/&amp;quot; /&amp;gt;&lt;br /&gt;					&amp;lt;/baseAddresses&amp;gt;&lt;br /&gt;				&amp;lt;/host&amp;gt;&lt;br /&gt;				&amp;lt;endpoint address=&amp;quot;mex&amp;quot; binding=&amp;quot;mexHttpBinding&amp;quot; contract=&amp;quot;WcfService.ISecureService&amp;quot;/&amp;gt;&lt;br /&gt;	&amp;lt;/service&amp;gt;&lt;br /&gt;&amp;lt;/services&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now that we know the server is expecting username and password, we want a custom validator which checks this username and password combination against our custom repository of users. To do that, we would have to configure the service behavior this time. So binding ensures credentials are being passed and the service behavior validates them! ;)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt; &amp;lt;serviceBehaviors&amp;gt;&lt;br /&gt;				&amp;lt;behavior name=&amp;quot;secureBehavior&amp;quot;&amp;gt;&lt;br /&gt;					&amp;lt;serviceMetadata httpGetEnabled=&amp;quot;true&amp;quot; /&amp;gt;&lt;br /&gt;					&amp;lt;serviceDebug includeExceptionDetailInFaults=&amp;quot;true&amp;quot; /&amp;gt;					&lt;br /&gt;					&lt;br /&gt;					&amp;lt;serviceCredentials&amp;gt;&lt;br /&gt;						&lt;br /&gt;						&amp;lt;serviceCertificate&lt;br /&gt;							findValue=&amp;quot;wcfSecureService&amp;quot;&lt;br /&gt;							storeLocation=&amp;quot;LocalMachine&amp;quot;&lt;br /&gt;							storeName=&amp;quot;My&amp;quot;&lt;br /&gt;							x509FindType=&amp;quot;FindBySubjectName&amp;quot; /&amp;gt;&lt;br /&gt;						&lt;br /&gt;						&amp;lt;!-- &lt;br /&gt;						Now in secureBinding (see in bindings section), &lt;br /&gt;						we set the Message security to use &amp;quot;UserName&amp;quot;&lt;br /&gt;						as ClientCredentialType. So we would like to&lt;br /&gt;						use a custom username password validator.&lt;br /&gt;						Here we specify that our custom validator should be used.&lt;br /&gt;						--&amp;gt;						&lt;br /&gt;						&amp;lt;userNameAuthentication&lt;br /&gt;							userNamePasswordValidationMode=&amp;quot;Custom&amp;quot;&lt;br /&gt;							customUserNamePasswordValidatorType=&amp;quot;WcfService.CustomUserNamePasswordValidator, WcfService&amp;quot; /&amp;gt;&lt;br /&gt;					&amp;lt;/serviceCredentials&amp;gt;&lt;br /&gt;					&lt;br /&gt;					&lt;br /&gt;					&amp;lt;!-- &lt;br /&gt;					The Custom Authorization policy is what used to verify the roles.&lt;br /&gt;					For a Role specified in the PrincipalPermission attribute,&lt;br /&gt;					IsInRole() method in the Principal that was set from the &lt;br /&gt;					CustomAuthorizationPolicy.Evaluate would be invoked.					&lt;br /&gt;					--&amp;gt;&lt;br /&gt;					&amp;lt;serviceAuthorization principalPermissionMode=&amp;#39;Custom&amp;#39;&amp;gt;&lt;br /&gt;						&amp;lt;authorizationPolicies&amp;gt;&lt;br /&gt;							&amp;lt;add policyType=&amp;#39;WcfService.CustomAuthorizationPolicy, WcfService&amp;#39; /&amp;gt;&lt;br /&gt;						&amp;lt;/authorizationPolicies&amp;gt;&lt;br /&gt;					&amp;lt;/serviceAuthorization&amp;gt;&lt;br /&gt;					&lt;br /&gt;				&amp;lt;/behavior&amp;gt;&lt;br /&gt;&amp;lt;/serviceBehaviors&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;In the above configuration, using the serviceCredentials\userNameAuthentication element we specify that the userName/password are to be validated using custom validator type.&lt;br /&gt;This is all configured there. While the username and password authenticates the client on the service, I think it does not really do anything to the communication channel. &lt;br /&gt;To make the channel secure, we make use of certificates. In order to do this, the following steps are required to be done on the development machine so that the sample gets working :&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;Using the makecert application (can run from Visual Studio Command), create and register the command for exchanging. Note that if you follow the MSDN article on creating certificates using makecert, it does not tell you about enabling the certificate such that it is suitable for key exchanging. So the command that worked for me is &lt;/br/&gt;&lt;br /&gt;&lt;p&gt; makecert.exe -sr LocalMachine -ss MY -a sha1 -n CN="wcfSecureService" -sky exchange -pe -r wcfSecureService.cer &lt;/p&gt; &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt;&lt;br /&gt;We specify the same certificate to be used in the service configuration file using the serviceCredentials\serviceCertificate element. See the configuration snippet shown previously. It basically says "find the certificate by subject name where subject name is 'wcfSecureService' in the certificate store on the local machine and the store would be Personal". For all this to work, note that HTTPS base address should be used.&lt;/li&gt;&lt;br /&gt;&lt;br /&gt;&lt;li&gt; While the first two steps takes care of the certificate on the server, the client should have some knowledge (basically the client should know the public key with which the messages would be encrypted) of the existence of the certificate. we specify that in the endpoint\identity section of the client configuration [see below]. The encodedValue can be obtained by adding service reference from Visual Studio which generates shit load of configuration on the client, just save the encodedValue and revamp your configuration file. &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;client&amp;gt;&lt;br /&gt;			&amp;lt;endpoint address=&amp;quot;http://truebuddi:8080/secureService&amp;quot; binding=&amp;quot;wsHttpBinding&amp;quot;&lt;br /&gt;					  bindingConfiguration=&amp;quot;secureWsHttpBinding&amp;quot;&lt;br /&gt;					  behaviorConfiguration=&amp;quot;ignoreCert&amp;quot;&lt;br /&gt;					  contract=&amp;quot;SecurityDemo.ISecureService&amp;quot;&amp;gt;&lt;br /&gt;				&amp;lt;identity&amp;gt;&lt;br /&gt;					&amp;lt;!-- Don&amp;#39;t panic this key is wrong ;) for the sake of this post--&amp;gt;&lt;br /&gt;					&amp;lt;certificate encodedValue=&amp;quot;AwAAAAEAAAAUAAAAee8O3PpkfSCfjaa3mDmkK+HLb4QgAAAAAQAAAAcCAAAwggIDMIIBcKADAgECAhDgA4A6S0Z/j0d3IFg04e9gMAkGBSsOAwIdBQAwGzEZMBcGA1UEAxMQd2NmU2VjdXJlU2VydmljZTAeFw0xMDA1MDUyMzQ4NTZaFw0zOTEyMzEyMzU5NTlaMBsxGTAXBgNVBAMTEHdjZlNlY3VyZVNlcnZpY2UwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALF7OJsZ6AV5yqSSQyne9j+xwdRLDRoVMleYg0vGvB7W7Bk5zBNbSDCbb+spJR3ykayDoZYpykyY8Q7qzvPuUPdHu7SkMVZ9Ng8B8yAq0zrD8sJwnaqTEY4a8mj8Dt86Yr0wK31aF4VSDRZaK+XDyFd5hWU8Eya+bohhixndMYwNAgMBAAGjUDBOMEwGA1UdAQRFMEOAEJRtYMFDVIgPHFrIf0LU5e+hHTAbMRkwFwYDVQQDExB3Y2ZTZWN1cmVTZXJ2aWNlghDgA4A6S0Z/j0d3IFg04e9gMAkGBSsOAwIdBQADgYEApQ+Hy6e4hV5rKRn93IMcEL3tW2tUYcj/oifGbEPRX329s3cc8QH6jYaNN8cgS5RN+6QffrkvupMSUauGsWia20WHTRI8lyb+1gvvX4NpTxZE6+sZkvIu6R/qIsC6V9pbRCHm3HRFnAoMNZmPTr5mJvzwAQZzOdXMFq0OwakJKEw=&amp;quot; /&amp;gt;					&lt;br /&gt;				&amp;lt;/identity&amp;gt;&lt;br /&gt;			&amp;lt;/endpoint&amp;gt;&lt;br /&gt;&amp;lt;/client&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can also look at this &lt;a href="http://msdn.microsoft.com/en-us/library/system.security.cryptography.x509certificates.publickey.encodedkeyvalue(VS.85).aspx"&gt;link&lt;/a&gt; to get the public key in any case.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;For testing purposes, you should also add a behaviorConfiguration on the client's endpoint such that certificates are not validated, once you deploy, you can remove this behavior.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;behaviors&amp;gt;&lt;br /&gt;			&amp;lt;endpointBehaviors&amp;gt;&lt;br /&gt;				&amp;lt;!-- ignore cerificates validation for testing purposes. --&amp;gt;&lt;br /&gt;				&amp;lt;behavior name=&amp;quot;ignoreCert&amp;quot;&amp;gt;&lt;br /&gt;					&amp;lt;clientCredentials&amp;gt;&lt;br /&gt;						&amp;lt;serviceCertificate&amp;gt;&lt;br /&gt;							&amp;lt;authentication certificateValidationMode=&amp;quot;None&amp;quot; /&amp;gt;&lt;br /&gt;						&amp;lt;/serviceCertificate&amp;gt;&lt;br /&gt;					&amp;lt;/clientCredentials&amp;gt;&lt;br /&gt;				&amp;lt;/behavior&amp;gt;&lt;br /&gt;			&amp;lt;/endpointBehaviors&amp;gt;&lt;br /&gt;&amp;lt;/behaviors&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; On the client config, you should also give the same wsHttpBinding with similar behavior but with few other options added. See snippet and compare it with the binding snippet that was shown earlier for the server &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;bindings&amp;gt;&lt;br /&gt;			&amp;lt;wsHttpBinding&amp;gt;&lt;br /&gt;				&amp;lt;binding name=&amp;quot;secureWsHttpBinding&amp;quot;&amp;gt;&lt;br /&gt;					&amp;lt;security mode=&amp;quot;Message&amp;quot;&amp;gt;&lt;br /&gt;						&amp;lt;message clientCredentialType=&amp;quot;UserName&amp;quot; &lt;br /&gt;								 negotiateServiceCredential=&amp;quot;true&amp;quot; &lt;br /&gt;								 establishSecurityContext=&amp;quot;true&amp;quot;/&amp;gt;&lt;br /&gt;					&amp;lt;/security&amp;gt;&lt;br /&gt;				&amp;lt;/binding&amp;gt;&lt;br /&gt;			&amp;lt;/wsHttpBinding&amp;gt;&lt;br /&gt;&amp;lt;/bindings&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;With this the communication channel is secure. You might have some issues with Certificates but you should be able to use the exception messages to bing for answers online in the forums. Only other part that is left on the client end is to make sure that the client proxy used are set with Username and password. Code for the full client is shown below. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt; SecureServiceClient client = new SecureServiceClient();&lt;br /&gt; client.ClientCredentials.UserName.UserName = "Krishna";&lt;br /&gt; client.ClientCredentials.UserName.Password = "test";&lt;br /&gt; User test = client.Login();&lt;br /&gt; client.SafeOperationByAdmin();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;2. UserName and Password Custom Validation&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Implement a type that derives from UserNamePasswordValidator class. You would have to reference the System.IdentityModel.dll and if you remember, we set the custom validator in the service behavior on the service configuration file. While the code shown below does not talk to DB, it should still serve as a good example on custom username and password validation. Note that this Validate() method gets called for evevery&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;  public class CustomUserNamePasswordValidator : UserNamePasswordValidator&lt;br /&gt;    {&lt;br /&gt;        public override void Validate(string userName, string password)&lt;br /&gt;        {&lt;br /&gt;            Console.WriteLine("Username validation started");&lt;br /&gt;            if (userName == "Krishna" &amp;&amp; password == "test")&lt;br /&gt;                return;&lt;br /&gt;            throw new InvalidCredentialException("Invalid credentials passed to the service");&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;3. Restriction of Operations using Roles &lt;/h3&gt;&lt;br /&gt;&lt;p&gt;The operations can be restricted to users of certain roles by applying a PrincipalPermission attribute on the OperationContract [see below]. The current principal would be checked to see if it is in the role specified, otherwise the operation would not allowed to be executed. Now how do we set this Principal to something? To do this, we need a CustomPrincipal which you should derive from IPrincipal. This Principal implementation has IIdentity which can be WindowsIndetity for Windows Authentication and GenericIdentity for other scenarios. Now this CustomPrincipal should be created and applied somewhere right? This is where the IAuthorizationPolicy comes into play, We should have a custom authorization policy whose Evaluate method should take care of fetching the identity and passing it to a newly created custom principal. This custom principal has to be set as the current principal. All the three code snippets : PrincipalPermission attribute on operations, CustomPrincipal and CustomAuthorizationPolicy is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;///&lt;br /&gt;///This authorization policy is set on the service behavior using service authorization element.&lt;br /&gt;public class CustomAuthorizationPolicy : IAuthorizationPolicy&lt;br /&gt;{&lt;br /&gt;        public bool Evaluate(EvaluationContext evaluationContext, ref object state)&lt;br /&gt;        {&lt;br /&gt;            IIdentity client = (IIdentity)(evaluationContext.Properties["Identities"] as IList)[0];&lt;br /&gt;            // set the custom principal&lt;br /&gt;            evaluationContext.Properties["Principal"] = new CustomPrincipal(client);&lt;br /&gt;            return true;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        private IIdentity GetClientIdentity(EvaluationContext evaluationContext)&lt;br /&gt;        {&lt;br /&gt;            return null;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public System.IdentityModel.Claims.ClaimSet Issuer&lt;br /&gt;        {&lt;br /&gt;            get { throw new NotImplementedException(); }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public string Id&lt;br /&gt;        {&lt;br /&gt;            get { throw new NotImplementedException(); }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;public class CustomPrincipal : IPrincipal&lt;br /&gt;    {&lt;br /&gt;        private IIdentity identity;&lt;br /&gt;&lt;br /&gt;        public CustomPrincipal(IIdentity identity)&lt;br /&gt;        {&lt;br /&gt;            this.identity = identity;&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public IIdentity Identity&lt;br /&gt;        {&lt;br /&gt;            get&lt;br /&gt;            {&lt;br /&gt;                return identity;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public bool IsInRole(string role)&lt;br /&gt;        {&lt;br /&gt;            return true;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;br /&gt;///in the WCF Service implementation&lt;br /&gt;[PrincipalPermission(SecurityAction.Demand, Role = "Admin")]&lt;br /&gt;public void SafeOperationByAdmin()&lt;br /&gt;{&lt;br /&gt;///more code&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The newly created Authorization Policy should be configured inside the service configuration file in the serviceBehavior\serviceAuthorization as shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;!-- &lt;br /&gt;The Custom Authorization policy is what used to verify the roles.&lt;br /&gt;For a Role specified in the PrincipalPermission attribute,&lt;br /&gt;IsInRole() method in the Principal that was set from the &lt;br /&gt;CustomAuthorizationPolicy.Evaluate would be invoked.					&lt;br /&gt;--&amp;gt;&lt;br /&gt;&amp;lt;serviceAuthorization principalPermissionMode=&amp;#39;Custom&amp;#39;&amp;gt;&lt;br /&gt;		&amp;lt;authorizationPolicies&amp;gt;&lt;br /&gt;			&amp;lt;add policyType=&amp;#39;WcfService.CustomAuthorizationPolicy, WcfService&amp;#39; /&amp;gt;&lt;br /&gt;		&amp;lt;/authorizationPolicies&amp;gt;&lt;br /&gt;&amp;lt;/serviceAuthorization&amp;gt;&lt;br /&gt;					&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;To summarize, the following are the steps that should be performed to get the security working in WCF. (Message level security).&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;li&gt; Create and register a certificate. Configure the service configuration specifying the certificate to use. This is done in the bindingConfiguration and the binding configuration is then applied on the endpoint.&lt;br /&gt;&lt;li&gt; Configure the service to make use of Message level security. Again done on the server configuration.&lt;br /&gt;&lt;li&gt; Configure the client to use encodedValue for its communication which is the public key. This is done in the bindingConfiguration on the client's endpoint. For testing purposes you can make the client not validate the certificates. This is done on the end point behaviors.&lt;br /&gt;&lt;li&gt; Configure the client's binding to make use of Message level security with UserName.&lt;br /&gt;&lt;li&gt; The client's code should specify the username and password. To validate this information, register a custom UserNamePasswordValidator in the serviceBehavior on the server configuration.&lt;br /&gt;&lt;li&gt; For roles, create a custom prinicipal and set it using a Custom Authorization policy. This authorization policy should be registered in the serviceAuthorization of the serviceBehavior in the server configuration file.&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;Again the code is available for download at : http://drop.io/yskic3h . Sometime, in the future, I would try to upload the code to codeplex or put it in the Windows Live Skydrive.  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-6532311396829523790?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/6532311396829523790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=6532311396829523790' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/6532311396829523790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/6532311396829523790'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/05/wcf-security-way-i-wanted-to-learn.html' title='WCF Security – the way I wanted to learn'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-448864845158235795</id><published>2010-04-15T06:07:00.001-07:00</published><updated>2010-04-15T06:07:16.928-07:00</updated><title type='text'>Running Moles using NUnit Console from Visual Studio</title><content type='html'>&lt;p&gt;Create an external tool in Visual Studio as shown below&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/S8cPghQVkZI/AAAAAAAABLE/GRguELA8sS0/s1600-h/image%5B3%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/S8cPhJO31tI/AAAAAAAABLI/_40bTSW4fIE/image_thumb%5B1%5D.png?imgmax=800" width="475" height="462" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Command : C:\Program Files (x86)\Microsoft Moles\bin\moles.runner.exe &lt;/p&gt;  &lt;p&gt;Arguments: $(BinDir)/$(TargetName).dll /runner:&amp;quot;c:\Development Tools\NUnit 2.5.2\bin\net-2.0\nunit-console.exe&amp;quot; /x86&lt;/p&gt;  &lt;p&gt;Initialize Directory : $(ProjectDir)&lt;/p&gt;  &lt;p&gt;Now you can use Moles from within Visual Studio. :)&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-448864845158235795?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/448864845158235795/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=448864845158235795' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/448864845158235795'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/448864845158235795'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/04/running-moles-using-nunit-console-from.html' title='Running Moles using NUnit Console from Visual Studio'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/S8cPhJO31tI/AAAAAAAABLI/_40bTSW4fIE/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-6260614443056046186</id><published>2010-03-18T19:27:00.001-07:00</published><updated>2010-03-18T19:27:11.870-07:00</updated><title type='text'>Introducing Comfy.Couch, a CouchDB API for .NET</title><content type='html'>&lt;p&gt;WARNING : The work is still in progress.&lt;/p&gt;  &lt;p&gt;From the past few days, I have been working on coming up with a nice little .NET Library that one could use with CouchDB. My goal was to stick with the CouchDB API documentation as much as I can so that it would be easier to work with the driver. The library has dependencies on Log4Net and Json.NET libraries.&lt;/p&gt;  &lt;p&gt;I tried to be over-smart when picking that name – Comfy.Couch (I meant a comfortable couch to use :)). At the moment, the database API is functionally complete, but you cannot really use it unless you have the Document API which would be coming soon. The reference is at &lt;a href="http://wiki.apache.org/couchdb/HTTP_database_API"&gt;http://wiki.apache.org/couchdb/HTTP_database_API&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I made sure I wrote unit tests to cover most part of my code, but I did miss some pieces here and there.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/S6Lg_K66wJI/AAAAAAAABK8/Six65bmoCK4/s1600-h/image%5B3%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/S6Lg_zEW4zI/AAAAAAAABLA/3mxI52gD8Tw/image_thumb%5B1%5D.png?imgmax=800" width="644" height="369" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;So I ended up having 94% of code coverage so far and I will be adding tests soon.&lt;/p&gt;  &lt;p&gt;My idea is to first get the complete API in place and then worry about where it has to be tuned. So far, I have not focused on any kind of tuning, which I think could be done. I have thrown in a few asynchronous requests here and there but they are yet to be tested.&lt;/p&gt;  &lt;p&gt;1. Creating a database.&lt;/p&gt; &lt;pre name="code" class="c#"&gt;&lt;br /&gt;CouchDatabaseOperations.Create("databasename"); //validation on database names is pending. &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;2. Getting database information from the server&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="c#"&gt;&lt;br /&gt;ICouchDatabase db = CouchDatabaseOperations.Get("databasename");&lt;br /&gt;CouchDatabaseInfo info = db.Metadata; &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;3. Deleting the database&lt;/p&gt;&lt;br /&gt;&lt;pre name="code" class="c#"&gt;&lt;br /&gt;//Delete operation uses MaxRetries as 2 since most of the times the first delete request fails on Windows.&lt;br /&gt;CouchDatabaseOperations.Delete("databasename"); &lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;While I have successfully completed the rest of the API that is described in the Database API reference at CouchDB website, I just showed how the library could be used in here. The unit tests might be more helpful for you to get started, if you are interested.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Next steps: &lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt; Upload the sourcecode to comfy.codeplex.com&lt;br /&gt;&lt;li&gt; Improvize logging information&lt;br /&gt;&lt;li&gt; Work on the Document API&lt;br /&gt;&lt;li&gt; Work on the View API&lt;br /&gt;&lt;li&gt; Work on the Bulk Document API&lt;br /&gt;&lt;li&gt; Run some performance tests and identify the bottlenecks in the driver.&lt;br /&gt;&lt;li&gt; Sample Scrum Management tool in Silverlight 4 that uses CouchDB for data backend.&lt;br /&gt;&lt;/ul&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-6260614443056046186?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/6260614443056046186/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=6260614443056046186' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/6260614443056046186'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/6260614443056046186'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/03/introducing-comfycouch-couchdb-api-for.html' title='Introducing Comfy.Couch, a CouchDB API for .NET'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_Oy9HuksgrdU/S6Lg_zEW4zI/AAAAAAAABLA/3mxI52gD8Tw/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-5823565687832466803</id><published>2010-02-10T19:24:00.001-08:00</published><updated>2010-02-10T19:24:28.482-08:00</updated><title type='text'>Using .NET 3.5 (CLR 2.0) DLL inside Visual Studio 2010 for a .NET 4.0 Project/Application</title><content type='html'>&lt;p&gt;When you first create a .NET 4.0 project inside VS 2010 and add reference to a .NET 3.5 DLL (say log4net or Rhino.Mocks), the project tends to not build. You can get errors as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/S3N4aGcY8iI/AAAAAAAABKo/13NGfYQ2S3c/s1600-h/image%5B3%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/S3N4aRt67MI/AAAAAAAABKs/_y5ynd5233k/image_thumb%5B1%5D.png?imgmax=800" width="644" height="89" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;It might appear to be a CLR version issue – unable to run 2.0 DLL inside a 4.0 App Domain. And i thought that is what it was until now. &lt;/p&gt;  &lt;p&gt;You can get over this :) &lt;/p&gt;  &lt;p&gt;By default, VS 2010 creates the projects with Target Framework on the properties set to “.NET Framework 4 Client Profile”. You would have to change that to “.NET Framework 4” by going to Project Properties –&amp;gt; Application –&amp;gt;&amp;#160; Target Framework. And every thing begins to compile.&lt;/p&gt;  &lt;p&gt;So I guess, one has to be aware of this when migrating old solutions from Visual Studio 2008 to Visual Studio 2010.&lt;/p&gt;  &lt;p&gt;Proof that it works :) Notice the .NET Framework 4.0 features as well Log4Net and Rhino.Mocks used in all the same example. (It is a stupid example, but the intention was to show it works).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/S3N4ak4QpfI/AAAAAAAABKw/BnKnGThCkVw/s1600-h/image%5B9%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/S3N4a-SvWvI/AAAAAAAABK0/EpHt1R8INq4/image_thumb%5B5%5D.png?imgmax=800" width="819" height="592" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;If for some reason, it does not work for you, try to add &lt;/p&gt;  &lt;p&gt;&amp;lt;?xml version =&amp;quot;1.0&amp;quot;?&amp;gt;   &lt;br /&gt;&amp;lt;configuration&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;startup useLegacyV2RuntimeActivationPolicy=&amp;quot;true&amp;quot;&amp;gt;    &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;lt;supportedRuntime version=&amp;quot;v2.0.5727&amp;quot; /&amp;gt;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &amp;lt;supportedRuntime version=&amp;quot;v4.0.21006&amp;quot;/&amp;gt;    &lt;br /&gt;&amp;#160; &amp;lt;/startup&amp;gt;    &lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/p&gt;  &lt;p&gt;to your csc.exe.config/msbuild.exe.config/VCSExpress.exe.config/devenv.exe.config …&lt;/p&gt;  &lt;p&gt;I initially thought it has something to do with not enabling Side-By-Side Execution of the&amp;#160; compiler and stuff but it turns out that it is not the case. For your information,&lt;strong&gt;&amp;#160; i have added supported runtime as .NET 2.0 &lt;u&gt;but then commented it to be sure that its ONLY the Target Framework that has to be changed.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-5823565687832466803?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/5823565687832466803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=5823565687832466803' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5823565687832466803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5823565687832466803'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/02/using-net-35-clr-20-dll-inside-visual.html' title='Using .NET 3.5 (CLR 2.0) DLL inside Visual Studio 2010 for a .NET 4.0 Project/Application'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/S3N4aRt67MI/AAAAAAAABKs/_y5ynd5233k/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-7367713592991837094</id><published>2010-02-04T16:53:00.001-08:00</published><updated>2010-02-04T16:53:08.243-08:00</updated><title type='text'>Breaking my head with message passing and Scala Actors</title><content type='html'>&lt;p&gt;I recently started working on a personal project on which a friend of mine is helping. After some discussion, we thought Scala might be a good bet to use as the development platform of our choice (and we integrate Spring into Scala). Anyway for that, I got into Scala actors. Actors appear easy code – all you have to do is create an actor (if you use Actor.actor construct, it starts automatically, otherwise you have to invoke start) and from somewhere keep sending messages to the Actor.&lt;/p&gt;  &lt;p&gt;So let us first define what message that I want to send using Case Classes. Refer the documentation on case classes.&lt;/p&gt;  &lt;pre name="code" class="scala"&gt;&lt;br /&gt;case class Message(someData : String)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now let us create our component which is an Actor and for each string passed in the constructor, we append the message (Some stupid behavior, but serves the example here)&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;class MyActor(toInform: Array[String]) extends scala.actors.Actor{&lt;br /&gt;  private val noticeTo = toInform&lt;br /&gt;  def act(){&lt;br /&gt;    loop{&lt;br /&gt;      react{&lt;br /&gt;        case Message(r) =&gt;{&lt;br /&gt;            for(item&lt;-noticeTo)&lt;br /&gt;              println(item+"_"+r)&lt;br /&gt;          }&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now with the following code to test the above actor&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;val actor = new MyActor(Array("Krishna"))&lt;br /&gt;actor ! "Welcome"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;With all the excitement in the world, you run the test and it just hangs in there, nothing happens :). So you suddenly realize "YOU FORGOT TO START THE ACTOR". Damn! it was the actor.start that is causing the issue. So you cleverly add the actor.start statement. ("you" meaning "me")&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;val actor = new MyActor(Array("Krishna"))&lt;br /&gt;actor.start //do not forget this :)&lt;br /&gt;actor ! "Welcome"&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You run the test again, to have no success. Then you realize that your actor expects Message(r) where as you are sending a String. So you change that&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;val actor = new MyActor(Array("Krishna"))&lt;br /&gt;actor.start //do not forget this :)&lt;br /&gt;actor ! Message("Welcome")&lt;br /&gt;//actor.exit&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Also notice the commented out explicit kill of the exit call outside the actor. It is not advised to be doing that. Remeber that "!" is a send-and-continue kinda call (asynchronous call). So before the actor is scheduled to work on the message, it might be killed. Instead it is advised that you specify an "Exit" like message within the case on the Actor. Now you run the test and it works :) Hurray!!!!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; Later, smart-ass like you (this time, it is you :)), decide to write a very bad code (ok, you is not really you, for now lets assume the actor code i wrote is simply perfect) like shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;object Launcher extends Application{&lt;br /&gt;  val actor = new MyActor(null)&lt;br /&gt;  actor start() //do not forget this&lt;br /&gt;  actor ! Message("Welcome")&lt;br /&gt;  actor ! "E" //this is the exit message.&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You repeat the test again :) and this time it does nothing, it appears to be blocked :). Again....damn... so how would we know what the issue is? You spend a your day-off trying to figure out what is wrong with this simple code...then after spending 10 hours trying all the magic tricks (aparently, i know too many magic tricks that never work, hence the time), you realize the actor must be dead (netbeans threads view would show what threads are running and you never see any FJ Threads). So the actor died! So what can kill an actor? - call to exit(), or an exception!!!! There it is .. so let us change the actor code so that it can catch the exception.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;class MyActor(toInform: Array[String]) extends scala.actors.Actor{&lt;br /&gt;  private val noticeTo = toInform&lt;br /&gt;  def act(){&lt;br /&gt;    loop{&lt;br /&gt;      react{&lt;br /&gt;        case Message(r) =&gt;{&lt;br /&gt;            try{&lt;br /&gt;            for(item&lt;-noticeTo)&lt;br /&gt;              println(item+"_"+r)&lt;br /&gt;            }catch{&lt;br /&gt;              case e =&gt; e.printStackTrace&lt;br /&gt;            }&lt;br /&gt;          }&lt;br /&gt;        case "E" =&gt; exit&lt;br /&gt;      }&lt;br /&gt;    }&lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Run the test again and notice the stacktrace! &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;java.lang.NullPointerException&lt;br /&gt;        at scala.collection.mutable.ArrayOps$ofRef.length(ArrayOps.scala:68)&lt;br /&gt;        at scala.collection.IndexedSeqLike$class.foreach(IndexedSeqLike.scala:86)&lt;br /&gt;        at scala.collection.mutable.ArrayOps.foreach(ArrayOps.scala:20)&lt;br /&gt;        at tryscala.MyActor$$anonfun$act$1$$anonfun$apply$1.apply(Launcher.scala:13)&lt;br /&gt;        at tryscala.MyActor$$anonfun$act$1$$anonfun$apply$1.apply(Launcher.scala:10)&lt;br /&gt;        at scala.actors.Reaction$$anonfun$$init$$1.apply(Reaction.scala:33)&lt;br /&gt;        at scala.actors.Reaction$$anonfun$$init$$1.apply(Reaction.scala:29)&lt;br /&gt;        at scala.actors.ReactorTask.run(ReactorTask.scala:33)&lt;br /&gt;        at scala.actors.scheduler.ForkJoinScheduler$$anon$1.compute(ForkJoinScheduler.scala:111)&lt;br /&gt;        at scala.concurrent.forkjoin.RecursiveAction.exec(RecursiveAction.java:147)&lt;br /&gt;        at scala.concurrent.forkjoin.ForkJoinTask.quietlyExec(ForkJoinTask.java:422)&lt;br /&gt;        at scala.concurrent.forkjoin.ForkJoinWorkerThread.mainLoop(ForkJoinWorkerThread.java:340)&lt;br /&gt;        at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:325)&lt;br /&gt;BUILD SUCCESSFUL (total time: 7 seconds)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So the fix is to :) pass in an empty array at least, instead of sending in a null ( use Array.empty).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Clearly, this is not the exact sample that I was running, it was a little bit complicated and myself being totally new to Scala had a hard time trying to figure out that an exception can kill scala Actors!!! I know I am dumb, but with this post, I want to save you from considering yourself dumb after trying very hard for a few hours.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-7367713592991837094?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/7367713592991837094/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=7367713592991837094' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/7367713592991837094'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/7367713592991837094'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/02/breaking-my-head-with-message-passing.html' title='Breaking my head with message passing and Scala Actors'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-7161651667138977312</id><published>2010-01-26T15:56:00.001-08:00</published><updated>2010-01-26T15:56:30.513-08:00</updated><title type='text'>Dependency Injection in Scala and some other stuff</title><content type='html'>&lt;p&gt;My new&amp;#160; found love is the Java Spring framework. I initially looked at the SpringFramework for .NET and thought it was really good and well designed. But then for a pet project of mine, my friend promised to help me given the project would be on the JVM. So we decided that we shall consider Scala as the language of choice on the JVM. Now, I know how I can do DI using Spring Container in Java. So I was wondering if I could do the same in Scala. Turns out, it is not so difficult after all (so far).&lt;/p&gt;  &lt;p&gt;For my scala development environment, I played with Eclipse, IntelliJ Community Edition and then Netbeans. So far, Netbeans has the best support for Scala in the form of IDE integration. There are some issues with it but then it is not all too bad. One initial issue was that even though the Spring JAR files were in my class path, the netbeans editor complained that it could locate the Spring Jars. The error message was something like “the value springframework is not a member of the package org”. Turns out, if you clean and build the project, it would build successfully but the editor keeps complaining. The Netbeans wiki talked about having some “Reset Scala Parser” item on the context menu but I am so dumb that I still could not find it. So if there is no reset trigger then how about we close and start the IDE. And it works! For now, since I am using nightly builds (follow the wiki link here &lt;a href="http://wiki.netbeans.org/Scala68v1"&gt;http://wiki.netbeans.org/Scala68v1&lt;/a&gt;) I would not mind these minor issues. But let me tell you, I spent a whole evening trying to figure out which is the best IDE for latest Scala and the winner is Netbeans, without any question. &lt;/p&gt;  &lt;p&gt;Now at the time I created my sample project, I made sure that I check the settings in Netbeans project creation wizard which allows me to copy all my libraries into a common folder such that it would be easier when working as a team. Then I added the following files from the Spring Distribution.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/S1-BLLaqxvI/AAAAAAAABKg/dH3SOpNgizA/s1600-h/image%5B3%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/S1-BLSpfZaI/AAAAAAAABKk/Y2njS3PDl0U/image_thumb%5B1%5D.png?imgmax=800" width="644" height="251" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Apart from these, I added commons-logging jar too.&lt;/p&gt;  &lt;p&gt;Following code shows how you can use Spring within scala. So lets say I have an interface Sample. (which are almost traits in Scala). And I have a concrete implementation ScalaImpl. Follow the code carefully and with some fundamental understanding of Spring&amp;#160; framework, you should be all set.&lt;/p&gt;  &lt;pre name="code" class="scala"&gt;&lt;br /&gt;/** Main.scala **/&lt;br /&gt;package tryscala&lt;br /&gt;import org.springframework.context.support.FileSystemXmlApplicationContext&lt;br /&gt;&lt;br /&gt;object Main {&lt;br /&gt;&lt;br /&gt;  /**&lt;br /&gt;   * @param args the command line arguments&lt;br /&gt;   */&lt;br /&gt;  def main(args: Array[String]): Unit = {&lt;br /&gt;    val fs = new FileSystemXmlApplicationContext("Configs\\Spring.xml")&lt;br /&gt;    val sample = fs.getBean(classOf[Sample]).asInstanceOf[Sample]&lt;br /&gt;    println(sample sayHello)   &lt;br /&gt;  }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/** Sample.scala **/&lt;br /&gt;package tryscala&lt;br /&gt;&lt;br /&gt;trait Sample {&lt;br /&gt;  def sayHello(): String&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/** SampleImpl.scala"&lt;br /&gt;package tryscala&lt;br /&gt;&lt;br /&gt;class SampleImpl(var firstName:String) extends Sample {&lt;br /&gt;  def sayHello() = "Welcome to Scala : " + firstName&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; The spring configuration file (Configs\\Spring.xml) is shown below. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="xml"&gt;&lt;br /&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br /&gt;&amp;lt;beans xmlns=&amp;quot;http://www.springframework.org/schema/beans&amp;quot;&lt;br /&gt;       xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br /&gt;       xsi:schemaLocation=&amp;quot;http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;bean id=&amp;quot;sample&amp;quot; class=&amp;quot;tryscala.SampleImpl&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;constructor-arg name=&amp;quot;firstName&amp;quot; value=&amp;quot;Krishna Vangapandu&amp;quot;/&amp;gt;&lt;br /&gt;    &amp;lt;/bean&amp;gt;&lt;br /&gt;&amp;lt;/beans&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; I hope to be able to share more about what we are doing and how Scala effects us, as we move on. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-7161651667138977312?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/7161651667138977312/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=7161651667138977312' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/7161651667138977312'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/7161651667138977312'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/01/dependency-injection-in-scala-and-some.html' title='Dependency Injection in Scala and some other stuff'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_Oy9HuksgrdU/S1-BLSpfZaI/AAAAAAAABKk/Y2njS3PDl0U/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-8827792335542175873</id><published>2010-01-14T18:53:00.001-08:00</published><updated>2010-07-11T21:51:19.480-07:00</updated><title type='text'>Rhino Mocks : How to mock read-only properties.</title><content type='html'>&lt;p&gt;As part of my never-ending quest to do something big, I started working on an application for which I am learning to use Rhino Mocks and I thought it would make a small and easy example to understand mocks. I have not particularly followed TDD approach so far, but anyway here is my attempt to show how you would use Rhino Mocks to stub/mock (am yet to understand when to use what…I mean i know the difference … just did not develop enough maturity in that aspect).&lt;/p&gt;  &lt;p&gt;Let us say I have some interface which is as simple as shown below.&lt;/p&gt;  &lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;public interface IColumn {&lt;br /&gt;    public string Name { get; }&lt;br /&gt;    public string DataType { get; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; Now if I were to mock/stub this interface, I had some problems with Rhino Mocks throwing exceptions on how the property should have a getter/setter when I was trying to configure the mock such that whenever Name property is accessed you should return "Krishna Bhargava" and for DataType you should return "System.String". I tried different mechanims like using Expect.On(col).Call(it.Name).Return("Krishna Bhargava") or tried to define property behavior (PropertyBehavior()). Finally after struggling for an hour, looking at various examples online from good people like you and me, I was able to come up with proper code that can generate a stub for the column defined in this interface. The code snippet shows how you can use Rhino Mocks (which i think the most convenient framework - i tried Moq (somehow it does not click with me), NUnit.Mocks( too much ground work)) so that u can generate stubs for read-only properties! Unfortunately at the moment, I cannot comment much on the Rhino Mocks classes .. I hope the code snippet is easy to understand.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;private IColumn MockColumn(string name, string type)&lt;br /&gt;{&lt;br /&gt;            IColumn col = MockRepository.GenerateStub&lt;IColumn&gt;();&lt;br /&gt;            col.Stub(it =&gt; it.DataType).Return(Type.GetType(type));&lt;br /&gt;            col.Stub(it =&gt; it.Name).Return(name);            &lt;br /&gt;            return col;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; you can later use this method as shown below &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="csharp"&gt;&lt;br /&gt;[Test]&lt;br /&gt;public void ColumnStubNameCanBeSet()&lt;br /&gt;{&lt;br /&gt;            IColumn col = MockColumn("name", "String.String");&lt;br /&gt;            Assert.AreEqual("name",col.Name);&lt;br /&gt;            Assert.AreEqual(typeof(string), col.DataType);&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/*a little bit more real world usage of a column stub is shown below. */&lt;br /&gt;[Test]&lt;br /&gt;public void ValuesCanBeSetOnARecord()&lt;br /&gt;{&lt;br /&gt;            IRecord record = new Record(); //NOT DESCRIBED in this blog, but this is my personal class....&lt;br /&gt;            record.SetValue(MockColumn("name", "System.String"), "Krishna Vangapandu");&lt;br /&gt;            record.SetValue(MockColumn("age", "System.Int32"), 25);&lt;br /&gt;            Assert.AreEqual("Krishna Vangapandu",record.Value&lt;string&gt;("name"));&lt;br /&gt;            Assert.AreEqual(25, record.Value&lt;int&gt;("age"));&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;br /&gt;And by the way, Castle Windsor has the best and easiest configuration schema in all the IoC containers I played with. I personally like Unity Container but its configuration is a mess and over-engineered. I will try to post an implementation of Observer-Pattern where observers and observables are linked with pure configuration - the best use I made of IoC container so far!&lt;br /&gt;&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-8827792335542175873?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/8827792335542175873/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=8827792335542175873' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8827792335542175873'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8827792335542175873'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2010/01/rhino-mocks-how-to-mock-read-only.html' title='Rhino Mocks : How to mock read-only properties.'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4481600258063939075</id><published>2009-11-21T11:06:00.001-08:00</published><updated>2009-11-21T11:07:44.145-08:00</updated><title type='text'>Programming in Scala – Part 2/?</title><content type='html'>&lt;p&gt;In my &lt;a href="http://krishnabhargav.blogspot.com/2009/11/scala-for-dummies-like-me.html" target="_blank"&gt;previous post&lt;/a&gt;, we got started with simple Scala HelloWorld and moved on to write a bubble sort in Scala. This time let us look at some differences between a “var” and a “val” in scala. I hope you all know what “immutable” means – simply put Strings in Java/.NET are immutable. Anytime you modify a string, a new object of string is created – they cannot be changed in place. Well, in scala when you declare a variable with a “val” it would be immutable. Look at the following scala code.&lt;/p&gt;  &lt;pre class="scala" name="code"&gt;object ValVar&lt;br /&gt;{&lt;br /&gt;	def main(args: Array[String])&lt;br /&gt;	{&lt;br /&gt;		val immutableValue = 200&lt;br /&gt;		//immutableValue = 20 -&amp;gt; gives compiler error&lt;br /&gt;		var mutableValue = 200&lt;br /&gt;		mutableValue = 20&lt;br /&gt;		println(&amp;quot;Immutable : &amp;quot;+immutableValue+&amp;quot;\n Mutable  : &amp;quot;+mutableValue)&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The decompiled program would look like shown in Java&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="java" name="code"&gt;import java.rmi.RemoteException;&lt;br /&gt;import scala.Predef.;&lt;br /&gt;import scala.ScalaObject;&lt;br /&gt;import scala.ScalaObject.class;&lt;br /&gt;import scala.StringBuilder;&lt;br /&gt;import scala.runtime.BoxesRunTime;&lt;br /&gt;&lt;br /&gt;public final class ValVar$&lt;br /&gt;  implements ScalaObject&lt;br /&gt;{&lt;br /&gt;  public static final  MODULE$;&lt;br /&gt;&lt;br /&gt;  static&lt;br /&gt;  {&lt;br /&gt;    new ();&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public ValVar$()&lt;br /&gt;  {&lt;br /&gt;    MODULE$ = this;&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public void main(String[] args) {&lt;br /&gt;    int immutableValue = 200;&lt;br /&gt;&lt;br /&gt;    int mutableValue = 200;&lt;br /&gt;    mutableValue = 20;&lt;br /&gt;    Predef..MODULE$.println(new StringBuilder().append(&amp;quot;Immutable : &amp;quot;).&lt;br /&gt;			append(BoxesRunTime.boxToInteger(immutableValue)).&lt;br /&gt;			append(&amp;quot;\n Mutable  : &amp;quot;).&lt;br /&gt;			append(BoxesRunTime.boxToInteger(mutableValue)).toString());&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public int $tag()&lt;br /&gt;    throws RemoteException&lt;br /&gt;  {&lt;br /&gt;    return ScalaObject.class.$tag(this);&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Clearly, it does not look like &amp;quot;immutable&amp;quot; variables are declared final in the Java code. So it appears to me that Scala compiler does the job of making sure that the val'bles are immutable. For those curios to see what happens if you attempt to change a val'ble, see the screenshot below. Also it would be interesting to note that the scala compiler takes care of optimizing our string concatenation to make use of String builder, just like the javac!&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/Swg6JOQF4QI/AAAAAAAABHw/c8uTmVZJDZE/s1600-h/image%5B3%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/Swg6JYM8W6I/AAAAAAAABH0/s4SRPw6DWRE/image_thumb%5B1%5D.png?imgmax=800" width="436" height="75" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;b&gt;So what did we learn?&lt;/b&gt;: If you wish to keep changing the values for a variable, then use &amp;quot;var&amp;quot; and if you want immutable variables, use &amp;quot;var&amp;quot;.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now that we know how to create both variables and val’bles, let us look at some fancy stuff that we could do with lists.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Whats your range?&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Let us say, we need all odd numbers between 20 and 2000 which are divisible by both 5 and 7. If you were like me, we write the program to look like shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="scala" name="code"&gt;object RangeAction1&lt;br /&gt;{&lt;br /&gt;	def main(args: Array[String])&lt;br /&gt;	{&lt;br /&gt;		for(i &amp;lt;- 20 to 2000)&lt;br /&gt;		{&lt;br /&gt;			if( i % 5 == 0 &amp;amp;&amp;amp; i % 7 == 0)&lt;br /&gt;				println(i)&lt;br /&gt;		}&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Can we do any better? This looks too long now that I have been imagining things, increasing expectations about scala being so nice.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="scala" name="code"&gt;object RangeAction1&lt;br /&gt;{&lt;br /&gt;	def main(args: Array[String])&lt;br /&gt;	{&lt;br /&gt;		(20 to 2000).filter(i=&amp;gt;i%5==0&amp;amp;&amp;amp;i%7==0).foreach(i=&amp;gt;println(i))&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;When we say “20 to 2000”, it returns a &lt;a href="http://www.scala-lang.org/docu/files/api/scala/Range.html" target="_blank"&gt;Range&lt;/a&gt; object. Look in the documentation to see what all magic could we do with range. Similarly if we were to work with lists, we could do something similar. Now to add 1 cent to the 3 cents we covered so far, what if i want the range to start with 20 and end with 2000 but increment by 10 and exclusive of 2000.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="scala"&gt;&lt;br /&gt;(20 until 2000 by 10).filter{i=&gt; i % 5 == 0 &amp; i % 7 == 0}.foreach{i=&gt; println(i)}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Also, I wanted to be more like a regular programmer and put my closure inside {} instead of (). More fun later!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4481600258063939075?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4481600258063939075/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4481600258063939075' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4481600258063939075'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4481600258063939075'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/11/programming-in-scala-part-2.html' title='Programming in Scala – Part 2/?'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_Oy9HuksgrdU/Swg6JYM8W6I/AAAAAAAABH0/s4SRPw6DWRE/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4033060666521956310</id><published>2009-11-20T19:37:00.001-08:00</published><updated>2009-11-20T20:46:29.661-08:00</updated><title type='text'>Scala for dummies like me!</title><content type='html'>Well! what should I be saying? I am that kind of person who keeps shifting from one interest to another. Once I am extremely interested in .NET (and I still am, but .NET is now an ocean – would take me too long to catch up with everything) and now I want to explore Scala – all new programming language on the JVM (new to me!) which has been receiving rave reviews. So, I went ahead and ordered Programming in Scala book on a1books.com (which by the way is a great site) but unfortunately I did not receive my copy yet. So here i am with all intention to do something with Scala but am out of resources (no offense but there are no simple tutorial on Scala which is interesting and which doesn’t make me fall asleep in 2 minutes).   &lt;p&gt;Lets first get started and write a Hello World program.&lt;/p&gt;  &lt;pre class="scala" name="code"&gt;class HelloWorld&lt;br /&gt;{&lt;br /&gt;	def main(args: Array[String]){&lt;br /&gt;		println(&amp;quot;Krishna Vangapandu - Hello Scala world!&amp;quot;);&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;When you compile this and execute it, you would get a “java.lang.NoSuchMethodException: HelloWorld.main is not static”. Well, the mistake that I did was to put a “class” – but it should be object. So the hello world would be &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="scala" name="code"&gt;object HelloWorld&lt;br /&gt;{&lt;br /&gt;	def main(args: Array[String]){&lt;br /&gt;		println(&amp;quot;Krishna Vangapandu - Hello Scala world!&amp;quot;);&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So what's the difference between &amp;quot;class&amp;quot; and an &amp;quot;object&amp;quot;. Obviously there is no problem for the compiler, only the runtime blows! So what does the documentation say about this? Well even better lets use a decompiler to decompile the .class file we obtained and see how the scala code would when written in java. By the way, I am using &lt;a href="http://java.decompiler.free.fr/?q=jdgui#downloads" target="_blank"&gt;this decompiler&lt;/a&gt; - which i should say is freaking awesome.&lt;/p&gt;&lt;br /&gt;&amp;quot;class HelloWorld&amp;quot; decompiled. &lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="java" name="code"&gt;import java.rmi.RemoteException;&lt;br /&gt;import scala.Predef.;&lt;br /&gt;import scala.ScalaObject;&lt;br /&gt;import scala.ScalaObject.class;&lt;br /&gt;&lt;br /&gt;public class HelloWorld&lt;br /&gt;  implements ScalaObject&lt;br /&gt;{&lt;br /&gt;  public void main(String[] args)&lt;br /&gt;  {&lt;br /&gt;    Predef..MODULE$.println(&amp;quot;Krishna Vangapandu - Hello Scala world!&amp;quot;);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public int $tag()&lt;br /&gt;    throws RemoteException&lt;br /&gt;  {&lt;br /&gt;    return ScalaObject.class.$tag(this);&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&amp;quot;object HelloWorld&amp;quot; decompiled. &lt;br /&gt;  &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="java" name="code"&gt;import java.rmi.RemoteException;&lt;br /&gt;&lt;br /&gt;public final class HelloWorld&lt;br /&gt;{&lt;br /&gt;  public static final void main(String[] paramArrayOfString)&lt;br /&gt;  {&lt;br /&gt;    HelloWorld..MODULE$.main(paramArrayOfString);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  public static final int $tag()&lt;br /&gt;    throws RemoteException&lt;br /&gt;  {&lt;br /&gt;    return HelloWorld..MODULE$.$tag();&lt;br /&gt;  }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;But what the hell is a $tag() method? Well, I looked into the source code which had a comment on the $tag method which says &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;This method is needed for optimizing pattern matching expressions which match on constructors of case classes.  &lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Well, then what is the HelloWorld actually doing? Well, looks to me it was using the HelloWorld$ which was also generated by “scalac”. I cannot dig into what is&amp;#160; going on here, may be sometime in the future. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So far, what I understood is that “object” creates a final class whereas “class” creates a ScalaObject and methods inside would all be instance methods. So anything declared “object” can act only as a static-only container.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Lets do a simple &lt;a href="http://en.wikipedia.org/wiki/Bubble_sort#Step-by-step_example" target="_blank"&gt;bubble sort program&lt;/a&gt; in Scala. What should we be knowing to write a button sort?&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;ol&gt;&lt;br /&gt;  &lt;li&gt;Assuming we pass the numbers to sort from command line, how do we convert strings to numbers ? &lt;/li&gt;&lt;br /&gt;&lt;br /&gt;  &lt;li&gt;How do we loop the array? &lt;/li&gt;&lt;br /&gt;&lt;/ol&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="scala" name="code"&gt;object BubbleSort&lt;br /&gt;{&lt;br /&gt;	def main(ip_args: Array[String]) //we shall get the input numbers to sort into &amp;quot;args&amp;quot;&lt;br /&gt;	{&lt;br /&gt;		/*&lt;br /&gt;		we have a collection of strings, we should get a collection of numbers.&lt;br /&gt;		so we use the map which says for each i in the ip_args, &lt;br /&gt;		return the value after converting into expression. we  get a 1 to 1 returned array.		&lt;br /&gt;		*/&lt;br /&gt;		val args = ip_args.map { i =&amp;gt; Integer.parseInt(i)}&lt;br /&gt;		&lt;br /&gt;		/*&lt;br /&gt;		Looping : for index j which starts from 0 and ends at args.length-1 (inclusive)&lt;br /&gt;		*/&lt;br /&gt;		for(j &amp;lt;- 0 to args.length-1)&lt;br /&gt;		{&lt;br /&gt;			for(i &amp;lt;- 0 to args.length-2-j)&lt;br /&gt;			{&lt;br /&gt;				if(args(i) &amp;gt; args (i+1))&lt;br /&gt;				{&lt;br /&gt;					//we do an ascending order sort.&lt;br /&gt;					// Swap routine is shown belo.&lt;br /&gt;					val temp = args(i) //this is how we define variables in scala&lt;br /&gt;					args(i) = args(i+1)&lt;br /&gt;					args(i+1) = temp	&lt;br /&gt;				}&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;		//print all the numbers&lt;br /&gt;		for(i &amp;lt;- 0 to args.length-1)&lt;br /&gt;			println(args(i))&lt;br /&gt;	}&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I do agree that even without the comments the code does not look as concise as it should be. But right now, we are just getting started – we would slowly look at how we can write concise code when we think functional programming (I am saying this with my past experience with Groovy and C# Closures – by functional, 90% of the time I mean closures – which I know is not accurate).I have also observed that when you compile the BubbleSort.scala, you end up getting more than one .class files - which I believe is for the anonymous method (closure) we used.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;That's it! for this post. See you soon with functional programming using Scala! &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4033060666521956310?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4033060666521956310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4033060666521956310' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4033060666521956310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4033060666521956310'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/11/scala-for-dummies-like-me.html' title='Scala for dummies like me!'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-6918720422931519185</id><published>2009-11-12T08:07:00.001-08:00</published><updated>2009-11-12T08:09:02.714-08:00</updated><title type='text'>Working with JQuery and list boxes</title><content type='html'>&lt;p&gt;Code (read comments): &lt;/p&gt;  &lt;pre class="html" name="code"&gt;&amp;lt;html&amp;gt; &lt;br /&gt;&amp;lt;head&amp;gt; &lt;br /&gt;    &amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&amp;quot;&amp;gt; &lt;br /&gt;    &amp;lt;/script&amp;gt; &lt;br /&gt;    &amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt; &lt;br /&gt;        /* &lt;br /&gt;        when the document is ready (after all the HTML page is loaded, this shall be executed) &lt;br /&gt;        we attach the event handlers. &lt;br /&gt;        */ &lt;br /&gt;        $(document).ready(function(){ attachEventHandlers(); }); &lt;br /&gt;        function attachEventHandlers(){ &lt;br /&gt;            /* &lt;br /&gt;            In this method we attach the function(){} to the change event on all the &amp;lt;select&amp;gt; items. &lt;br /&gt;            The code inside the function(){} shall be executed when item selections are changed on the select box. &lt;br /&gt;            */ &lt;br /&gt;            $(&amp;quot;select&amp;quot;).change(function(){ &lt;br /&gt;                //using &amp;quot;this&amp;quot; to access the current listbox. the jQuery wrapper would be $(this) &lt;br /&gt;                var selectedItems = $(&amp;quot;:selected&amp;quot;,this); &lt;br /&gt;                $(&amp;quot;#itemsCount&amp;quot;).text(selectedItems.length); //set the items selected count. &lt;br /&gt;                var toAppendHtml = &amp;quot;&amp;quot;; //lets store the html that we shall put inside the itemsSelected element. &lt;br /&gt;                //for each selected item we add a new line with selected item's text and value to the toAppendHtml. &lt;br /&gt;                selectedItems.each(function(){ &lt;br /&gt;                    toAppendHtml += $(this).text() +&amp;quot; : &amp;quot;+$(this).val()+&amp;quot;&amp;lt;br/&amp;gt;&amp;quot;; &lt;br /&gt;                }); &lt;br /&gt;                //finally put everything in there as html content to itemsSelected. &lt;br /&gt;                $(&amp;quot;#itemsSelected&amp;quot;).html(toAppendHtml); &lt;br /&gt;            }); &lt;br /&gt;            /* &lt;br /&gt;            Alternatively you can use ExternalFunction. The external function should have one parameter &amp;quot;e&amp;quot; called the event object.            &lt;br /&gt;            $(&amp;quot;select&amp;quot;).click(ExternalFunction); &lt;br /&gt;            */ &lt;br /&gt;        } &lt;br /&gt;        /* &lt;br /&gt;        function ExternalFunction(e) &lt;br /&gt;        { &lt;br /&gt;        //now within this function, the element which raised the event can be accessed using &amp;quot;this&amp;quot;, or &amp;quot;e.currentTarget&amp;quot;. &lt;br /&gt;        //So the statement &amp;quot;this == e.currentTarget&amp;quot; will always be true. &lt;br /&gt;            alert($(&amp;quot;:selected&amp;quot;,this).length); &lt;br /&gt;        } &lt;br /&gt;        */ &lt;br /&gt;    &amp;lt;/script&amp;gt; &lt;br /&gt;    &amp;lt;style type=&amp;quot;text/css&amp;quot;&amp;gt; &lt;br /&gt;        select{ &lt;br /&gt;            width: 100px; &lt;br /&gt;            height: 200px; &lt;br /&gt;        } &lt;br /&gt;    &amp;lt;/style&amp;gt; &lt;br /&gt;&amp;lt;/head&amp;gt; &lt;br /&gt;&amp;lt;body&amp;gt; &lt;br /&gt;    &amp;lt;select name=&amp;quot;items&amp;quot; id=&amp;quot;items&amp;quot; multiple=&amp;quot;true&amp;quot;&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;1&amp;quot;&amp;gt;Item 1&amp;lt;/option&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;2&amp;quot;&amp;gt;Item 2&amp;lt;/option&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;3&amp;quot;&amp;gt;Item 3&amp;lt;/option&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;4&amp;quot;&amp;gt;Item 4&amp;lt;/option&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;5&amp;quot;&amp;gt;Item 5&amp;lt;/option&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;6&amp;quot;&amp;gt;Item 6&amp;lt;/option&amp;gt; &lt;br /&gt;        &amp;lt;option value=&amp;quot;7&amp;quot;&amp;gt;Item 7&amp;lt;/option&amp;gt;        &lt;br /&gt;    &amp;lt;/select&amp;gt; &lt;br /&gt;    &amp;lt;p/&amp;gt; &lt;br /&gt;    &amp;lt;div&amp;gt;total items selected : &amp;lt;span id=&amp;quot;itemsCount&amp;quot;&amp;gt;0&amp;lt;/span&amp;gt;&amp;lt;/div&amp;gt; &lt;br /&gt;    &amp;lt;span&amp;gt;Selected Items are &amp;lt;/span&amp;gt; &lt;br /&gt;    &amp;lt;div id=&amp;quot;itemsSelected&amp;quot;/&amp;gt; &lt;br /&gt;&amp;lt;/body&amp;gt; &lt;br /&gt;&amp;lt;/html&amp;gt;&lt;/pre&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-6918720422931519185?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/6918720422931519185/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=6918720422931519185' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/6918720422931519185'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/6918720422931519185'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/11/working-with-jquery-and-list-boxes.html' title='Working with JQuery and list boxes'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-7610987258151510555</id><published>2009-11-05T21:20:00.001-08:00</published><updated>2009-11-05T21:20:08.586-08:00</updated><title type='text'>Problem running Scala</title><content type='html'>&lt;p&gt;I was just trying to run scala on my machine and failed to do so with an error message “…..\java.exe unexpected at this time.” Look at the screenshot shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SvOyB_1mOMI/AAAAAAAABHQ/KTkg54VOgJ0/s1600-h/image%5B6%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SvOyCOu-IwI/AAAAAAAABHU/HlacqeXVaUw/image_thumb%5B2%5D.png?imgmax=800" width="644" height="327" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;Well, the problem was that environment variables for JAVA was set up using JAVA_HOME variable. The JAVA_HOME environment variable was pointing to the JDK directory and the Path was modified to include the “%JAVA_HOME%\bin” directory.&lt;/p&gt;  &lt;p&gt;I removed the JAVA_HOME and then modified the path to specify the complete path to the JDK bin folder and it works now. :)&lt;/p&gt;  &lt;p&gt;I might be talking more about Scala in the future, the concurrency scala supports appears to be interesting.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-7610987258151510555?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/7610987258151510555/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=7610987258151510555' title='8 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/7610987258151510555'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/7610987258151510555'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/11/problem-running-scala.html' title='Problem running Scala'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/_Oy9HuksgrdU/SvOyCOu-IwI/AAAAAAAABHU/HlacqeXVaUw/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>8</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-8422988679565280152</id><published>2009-08-31T20:05:00.001-07:00</published><updated>2009-08-31T20:05:37.951-07:00</updated><title type='text'>Visual Studio Test System : “Test Run Deployment Issue : The location of the file or directory … is not trusted”</title><content type='html'>&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SpyPfDQTk5I/AAAAAAAABGQ/zXSlTH_4zD4/s1600-h/image%5B6%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SpyPfgk1FdI/AAAAAAAABGU/vmsfbc2LUrw/image_thumb%5B4%5D.png?imgmax=800" width="1092" height="283" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;I just came across this issue when trying to run tests from Visual Studio test system. To resolve this, simple go to the source of the DLL (in my case, I placed them under LIB directory inside my solution directory), right click on each of the libraries that were taken from external sources (like Log4Net, Moq, etc.) and view the Properties. In the properties window, you should be seeing “Unblock” option as shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SpyPfx_p5hI/AAAAAAAABGY/ly2vtH8NtKk/s1600-h/image%5B12%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SpyPgaDwSWI/AAAAAAAABGc/JdQUnzrPf0g/image_thumb%5B8%5D.png?imgmax=800" width="381" height="519" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Simply click “Unblock” button and release the library’s security constraint. Now perform a clean on the solution and rebuild the solution. Your tests should run without any deployment issues. &lt;/p&gt;  &lt;p&gt;good luck!&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-8422988679565280152?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/8422988679565280152/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=8422988679565280152' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8422988679565280152'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/8422988679565280152'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/08/visual-studio-test-system-test-run.html' title='Visual Studio Test System : “Test Run Deployment Issue : The location of the file or directory … is not trusted”'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh4.ggpht.com/_Oy9HuksgrdU/SpyPfgk1FdI/AAAAAAAABGU/vmsfbc2LUrw/s72-c/image_thumb%5B4%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4722009388632703755</id><published>2009-07-27T21:37:00.001-07:00</published><updated>2009-07-27T21:59:29.571-07:00</updated><title type='text'>ConfigStation for WCF – prototype for minimal configuration based WCF services</title><content type='html'>&lt;p&gt;To start off, I would like to stress that I am not a WCF expert and if you go around my blog, you can notice me writing about lot of different things – WPF, DLR, Web Development and what not. So what I present is just something that I made recently as a part of a bigger project that I plan to release. Apparently, this is pretty good start for what I envision for avoiding Configuration Hell in WCF services.&lt;/p&gt;  &lt;p&gt;The &lt;a href="http://msdn.microsoft.com/en-us/netframework/bb499684.aspx"&gt;StockTrader sample from Microsoft comes with a great library – Configuration Service 2.04&lt;/a&gt;. The library is pretty good and provides wonderful functionality but the major problem with that, for me, is its strong dependency on the SQL Server backend. In short, the configuration service maintains a service configuration repository which is used to provide centralized configuration repository, load balancing, fail-over in WCF based SOA applications. And I always wanted such a repository which would minimize my effort in developing distributed applications using WCF.&lt;/p&gt;  &lt;p&gt;I believe, WCF should allow very simple way to develop services and should provide an easier means to configure them. One way away from configuration through App.Config is to code the configuration, but there seems to be a big lack of proper documentation and decent-real-world samples explaining code-based WCF configuration. Anyway, I would envision hosting a service to be as simple as :&lt;/p&gt; &lt;span class="c#" name="code"&gt;   &lt;p&gt;var serviceHost = new AutoConfiguredServiceHost&amp;lt;ServiceImpl&amp;gt;();&lt;/p&gt; &lt;/span&gt;  &lt;p&gt;With no or minimal configuration, the service host should be clever enough to determine what the configuration defaults are. Similarly, consuming the service should be as simple as :&lt;/p&gt; &lt;span class="c#" name="code"&gt;   &lt;p&gt;var client = new RemoteServiceProxy&amp;lt;IService&amp;gt;();&lt;/p&gt; &lt;/span&gt;  &lt;p&gt;The proxy should be created by accessing the repository to figure out implementation for IService and then use the configuration obtained to create the proxy.&lt;/p&gt;  &lt;p&gt;With these goals in mind, the config station has been developed and here is what I have so far.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Sample : Test Service which hosts the ConfigRepository as well as a sample WCF Service implementation. The host method is shown below.&lt;/strong&gt;&lt;/p&gt;  &lt;pre class="c#" name="code"&gt; class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            using (var configHost = new ConfigStationHost())&lt;br /&gt;            {&lt;br /&gt;                var hostFacade = new ServiceHostFacade&amp;lt;TestImpl&amp;gt;();&lt;br /&gt;                var host = hostFacade.Host;&lt;br /&gt;                host.Open();&lt;br /&gt;                Console.WriteLine(&amp;quot;Test service launched.Enter to Stop&amp;quot;);&lt;br /&gt;                Console.ReadLine();&lt;br /&gt;                //host.Close();&lt;br /&gt;                host.Abort();&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you look at the using block, I am creating an instance of ConfigStationHost – which actually hosts the ConfigStation – a repository WCF service. At the moment, this service requires App.Config based configuration of the service – which can be easily removed and which would be my next enhancement to the project. In this example, I am actually hosting the ConfigStation within the same process as my actual WCF service, which is not required at all. You can host the ConfigStation in a totally separate program – all you have to do is create the instance of ConfigStationHost (see required configuration below) and dispose it when you are done.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The configuration for the Test Service is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt; &lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;appsettings&amp;gt;&lt;br /&gt;    &amp;lt;add value=&amp;quot;net.tcp&amp;quot; key=&amp;quot;ServiceScheme&amp;quot; /&amp;gt; &amp;lt;!-- you can set this to http as well or even msmq ...--&amp;gt;&lt;br /&gt;    &amp;lt;add value=&amp;quot;9989&amp;quot; key=&amp;quot;ServicePort&amp;quot; /&amp;gt;&lt;br /&gt;  &amp;lt;/appsettings&amp;gt;&lt;br /&gt;  &lt;br /&gt;  &amp;lt;system.servicemodel&amp;gt;&lt;br /&gt;    &amp;lt;services&amp;gt;&lt;br /&gt;      &amp;lt;service name=&amp;quot;ConfigStation.Repository&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;endpoint contract=&amp;quot;ConfigStation.ServiceContracts.IRepository&amp;quot; binding=&amp;quot;wsHttpBinding&amp;quot; address=&amp;quot;http://localhost:8731/ConfigStation/Repository&amp;quot; /&amp;gt;&lt;br /&gt;      &amp;lt;/service&amp;gt;&lt;br /&gt;    &amp;lt;/services&amp;gt;&lt;br /&gt;    &lt;br /&gt;    &amp;lt;!-- This demo acts as a client to ConfigStation, so it is all good--&amp;gt;&lt;br /&gt;    &amp;lt;client&amp;gt;&lt;br /&gt;      &amp;lt;endpoint name=&amp;quot;ConfigStation&amp;quot; contract=&amp;quot;ConfigStation.ServiceContracts.IRepository&amp;quot; binding=&amp;quot;wsHttpBinding&amp;quot; address=&amp;quot;http://localhost:8731/ConfigStation/Repository&amp;quot;&amp;gt;&lt;br /&gt;      &amp;lt;/endpoint&amp;gt;&lt;br /&gt;    &amp;lt;/client&amp;gt;&lt;br /&gt;    &lt;br /&gt;  &amp;lt;/system.servicemodel&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In the shown configuration, the &amp;lt;service&amp;gt; element configuration is used to host the ConfigStation repository in the current process. The &amp;lt;client&amp;gt; configuration is&amp;#160; the WCF client configuration which is used to access the ConfigStation service hosted. The TestService makes interacts with the ConfigStation using WCF and the ConfigStation is treated as a WCF service hosted somewhere remote. So, if we were to host the configstation separately the only configuration required would be that of the &amp;lt;service&amp;gt; defined. The TestService would then have the AppSettings and the &amp;lt;client&amp;gt; configuration – which is pretty easy to set and even easier for me to remove.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now, the ServiceScheme dictates what communication protocol (BINDING, in terms of WCF) would be used when exposing the service and what binding would be used by the clients consuming this service. The ServicePort tells what port the service should be hosted on. Note that WCF allows hosting multiple services on the same port as long as their address is different (Except for MSMQ, i think).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;The test client to consume the TestService is a different program, whose configuration is shown below. The program contains a WCF client to the TestImpl service whose details are obtained from the ConfigStation. Thus, the client process requires configuration which points to the ConfigStation.&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;utf-8&amp;quot; ?&amp;gt;&lt;br /&gt;&amp;lt;configuration&amp;gt;&lt;br /&gt;  &amp;lt;system.serviceModel&amp;gt;&lt;br /&gt;  &amp;lt;client&amp;gt;&lt;br /&gt;    &amp;lt;endpoint address=&amp;quot;http://localhost:8731/ConfigStation/Repository&amp;quot; name=&amp;quot;ConfigStation&amp;quot;&lt;br /&gt;              binding=&amp;quot;wsHttpBinding&amp;quot;&lt;br /&gt;              contract=&amp;quot;ConfigStation.ServiceContracts.IRepository&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;/endpoint&amp;gt;&lt;br /&gt;  &amp;lt;/client&amp;gt;&lt;br /&gt;  &amp;lt;/system.serviceModel&amp;gt;&lt;br /&gt;&amp;lt;/configuration&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;As you can see, the above is the only configuration required – which would be eliminated once I enhance the ConfigStation. The actual code to access the client is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="xml" name="code"&gt;namespace Test.Client&lt;br /&gt;{&lt;br /&gt;    class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            var cf = new ClientProxyFacade&amp;lt;ITest&amp;gt;();&lt;br /&gt;            ITest test = cf.Interface;&lt;br /&gt;            var td = test.SayHello();&lt;br /&gt;            Console.WriteLine(&amp;quot;Remote Server returned : &amp;quot; + td.Message);&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You just create the ClientProxyFacade Of ITest, the service contract used by TestImpl. Then the interface is obtained via the “Interface” property. Then you can execute any method exposed by the Service Contract.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://configstation.codeplex.com/"&gt;The library is available on codeplex&lt;/a&gt; – making this my first public release of open source software, of any kind. In the process, I would like to stress that the library uses the amazing &lt;a href="http://www.idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;amp;tabid=11"&gt;ServiceModelEx library from Juval Lowy, IDesign.&lt;/a&gt; I actually tried to contact Juval whether or not to use his library but guess he is too busy so I took the liberty to publish the project having seen a WCF project on google code doing the same. In case I breach any license, please go easy on me and let me know so that I can fix my mistake. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I appreciate any positive feedback and any expert advice on the library. I am glad to learn and fix any changes requested. :) Hope this helps a few of us devs who like to play with some convention based WCF programming. I would be talking more details on the actual implementation, on how the library performs auto-generation of the service configuration and how bad the current repository implementation is, in my next post.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4722009388632703755?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4722009388632703755/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4722009388632703755' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4722009388632703755'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4722009388632703755'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/07/configstation-for-wcf-prototype-for.html' title='ConfigStation for WCF – prototype for minimal configuration based WCF services'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-466297902466510573</id><published>2009-07-22T18:22:00.000-07:00</published><updated>2009-07-22T18:49:05.475-07:00</updated><title type='text'>Powershell Script to delete bin/obj folders</title><content type='html'>Shown below is a simple powershell script that can be used to clean up a solution folder. The script excludes the "Libraries" directory and deletes any folder named bin or obj in the specified location.&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="C#"&gt;&lt;br /&gt;Get-childitem c:\Temp\MyProjectSolutionFolder -recurse -include *.exe,*.dll,*.pdb,*.exe.config, bin,obj | where {$_ -notmatch 'Libraries'} | Remove-Item -Recurse&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This script saves my time a lot and also does not require me to install any tools that does the same but adds registry entries for explorer context menu.&lt;br /&gt;&lt;br /&gt;NOTE: Please verify thoroughly before blindly running the script. Use the -WhatIf flag to simulate the execution of the command instead of actually running it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-466297902466510573?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/466297902466510573/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=466297902466510573' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/466297902466510573'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/466297902466510573'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/07/powershell-script-to-delete-binobj.html' title='Powershell Script to delete bin/obj folders'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-3151486619713774006</id><published>2009-06-20T13:35:00.001-07:00</published><updated>2009-06-20T13:35:28.074-07:00</updated><title type='text'>Bing : Not a search engine, but decision engine??</title><content type='html'>&lt;p&gt;I am an active contributor to the MSDN WPF Forums and most of the times I go to the forums through the search engine. And being an ardent supporter of Microsoft, I made Bing my default search engine on my home desktop. So I searched for “MSDN Social” and look what one of the sponsored result is!&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/Sj1ICzxCa8I/AAAAAAAAA60/e3WHDtqMUgs/s1600-h/image%5B4%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/Sj1ID84wrHI/AAAAAAAAA64/SR4_UZ9BLQM/image_thumb%5B2%5D.png?imgmax=800" width="570" height="458" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;seriously we are in the 21st century. And BING “decided” for me that I want to visit BAD GIRLS IN MY AREA! when all I wanted to do was to visit MSDN Social Forums. Bing – get a life.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-3151486619713774006?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/3151486619713774006/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=3151486619713774006' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/3151486619713774006'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/3151486619713774006'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/bing-not-search-engine-but-decision.html' title='Bing : Not a search engine, but decision engine??'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_Oy9HuksgrdU/Sj1ID84wrHI/AAAAAAAAA64/SR4_UZ9BLQM/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-5230903273834429597</id><published>2009-06-05T20:10:00.001-07:00</published><updated>2009-06-05T20:11:24.653-07:00</updated><title type='text'>GridViewColumn CellTemplate does not work?</title><content type='html'>&lt;p&gt;Well, today I came across this &lt;a href="http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/cfb7da87-391a-4dae-af8b-bd6312e12881"&gt;interesting question on WPF&lt;/a&gt; regarding setting the DataTemplate of a GridViewColumn not working properly. Everything looks fine in the code (assuming his DataTemplate generating method was fine) which got me interested to figure out what the issue is. &lt;/p&gt;  &lt;p&gt;And then I made up this sample application whose XAML is shown below.&lt;/p&gt;  &lt;pre class="xml" name="code"&gt;&amp;lt;Window x:Class=&amp;quot;Window1&amp;quot; &lt;br /&gt;  xmlns=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot; &lt;br /&gt;  xmlns:x=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot; &lt;br /&gt;  Title=&amp;quot;Window1&amp;quot; Height=&amp;quot;300&amp;quot; Width=&amp;quot;300&amp;quot; Loaded=&amp;quot;Window_Loaded&amp;quot;&amp;gt; &lt;br /&gt;&amp;lt;StackPanel&amp;gt; &lt;br /&gt;&amp;lt;ListView Name=&amp;quot;lv&amp;quot; ItemsSource=&amp;quot;{Binding Items}&amp;quot;&amp;gt; &lt;br /&gt;&amp;lt;ListView.View&amp;gt; &lt;br /&gt;&amp;lt;GridView&amp;gt;&amp;lt;/GridView&amp;gt; &lt;br /&gt;&amp;lt;/ListView.View&amp;gt; &lt;br /&gt;&amp;lt;/ListView&amp;gt;&lt;br /&gt;&amp;lt;/StackPanel&amp;gt; &lt;br /&gt;&amp;lt;/Window&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The code-behind is simple. It sets the DataContext to itself and then fetches sample data using GetData() call. Then the GridView for the ListView is obtained and a new gridviewcolumn is added programatically. The CellTemplate is set on the GridViewColumn using SampleTemplate() method. The SampleTemplate() method constructs a DataTemplate programatically using the FrameworkElementFactory class and returns the same. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre class="vb" name="code"&gt; &lt;br /&gt;Private Sub Window_Loaded(ByVal sender As System.Object, _&lt;br /&gt;                              ByVal e As System.Windows.RoutedEventArgs)&lt;br /&gt;        Me.DataContext = Me 'set the datacontext&lt;br /&gt;        Items = GetData()&lt;br /&gt;        Dim gv As GridView = CType(lv.View, GridView)&lt;br /&gt;        Dim gvc As New GridViewColumn&lt;br /&gt;        gvc.Header = &amp;quot;Test&amp;quot;&lt;br /&gt;        'Display member binding&lt;br /&gt;        gvc.DisplayMemberBinding = New Binding(&amp;quot;.&amp;quot;)&lt;br /&gt;        gvc.CellTemplate = SampleTemplate()&lt;br /&gt;        gv.Columns.Add(gvc)&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Private Function SampleTemplate() As DataTemplate&lt;br /&gt;        Dim dt As New DataTemplate&lt;br /&gt;        dt.DataType = GetType(String)&lt;br /&gt;        Dim fef As New FrameworkElementFactory(GetType(TextBox))&lt;br /&gt;        Dim bd As New Binding(&amp;quot;.&amp;quot;)&lt;br /&gt;        fef.SetBinding(TextBox.TextProperty, bd)&lt;br /&gt;        dt.VisualTree = fef&lt;br /&gt;        Return dt&lt;br /&gt;    End Function&lt;br /&gt;&lt;br /&gt;    Public Property Items() As IEnumerable(Of String)&lt;br /&gt;        Get&lt;br /&gt;            Return GetValue(ItemsProperty)&lt;br /&gt;        End Get&lt;br /&gt;&lt;br /&gt;        Set(ByVal value As IEnumerable(Of String))&lt;br /&gt;            SetValue(ItemsProperty, value)&lt;br /&gt;        End Set&lt;br /&gt;    End Property&lt;br /&gt;&lt;br /&gt;    Public Shared ReadOnly ItemsProperty As DependencyProperty = _&lt;br /&gt;                           DependencyProperty.Register(&amp;quot;Items&amp;quot;, _&lt;br /&gt;                           GetType(IEnumerable(Of String)), GetType(Window1), _&lt;br /&gt;                           New FrameworkPropertyMetadata(Nothing))&lt;br /&gt;&lt;br /&gt;    Function GetData() As IEnumerable(Of String)&lt;br /&gt;        Dim x As New ObservableCollection(Of String)&lt;br /&gt;        x.Add(&amp;quot;Item 1&amp;quot;)&lt;br /&gt;        x.Add(&amp;quot;Item 2&amp;quot;)&lt;br /&gt;        x.Add(&amp;quot;Item 3&amp;quot;)&lt;br /&gt;        Return x&lt;br /&gt;    End Function&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;And when I run the application all I see is …&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SineHTrdfpI/AAAAAAAAA6E/UsyBBRERj1M/s1600-h/image%5B7%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/SineJP2xy0I/AAAAAAAAA6I/D3e-NkgT70o/image_thumb%5B3%5D.png?imgmax=800" width="244" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Ok the binding works and I see my data but somehow the celltemplate is not being reflected. So, I was able to reproduce the issue the question presented.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So I dig around and looked in the &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.gridviewcolumn.celltemplate.aspx"&gt;documentation for CellTemplate&lt;/a&gt; where I found the following.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SineJErRMfI/AAAAAAAAA6M/d-8zFrReFIc/s1600-h/image%5B4%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SineJradgbI/AAAAAAAAA6Q/su90EFwS2gI/image_thumb%5B2%5D.png?imgmax=800" width="573" height="124" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So it basically means that if DisplayMemberBinding is used, then CellTemplate would be ignored and so on with the CellTemplateSelector. So I comment the line that sets DisplayMemberBinding and run again.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SineJy1JX_I/AAAAAAAAA6U/d0_0VWZB74E/s1600-h/image%5B11%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SineKSuNr1I/AAAAAAAAA6Y/8OVHo2RlAF4/image_thumb%5B5%5D.png?imgmax=800" width="466" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Yes! its working as expected.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So whats the moral of the story? Actually there are three morals:&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;1. First of all, when using CellTemplate, do not set DisplayMemberBinding.&lt;br /&gt;  &lt;br /&gt;2. Refer to the documentation, especially the remarks and code samples section for a method or property. MSDN folks did an amazing job (ofcourse the WPF guys as well).&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;3. MSDN WPF Forums is amazing and overall Microsoft.NET folks rocks big time.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-5230903273834429597?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/5230903273834429597/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=5230903273834429597' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5230903273834429597'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5230903273834429597'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/gridviewcolumn-celltemplate-does-not.html' title='GridViewColumn CellTemplate does not work?'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/SineJP2xy0I/AAAAAAAAA6I/D3e-NkgT70o/s72-c/image_thumb%5B3%5D.png?imgmax=800' height='72' width='72'/><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4712137523718038701</id><published>2009-06-04T12:02:00.001-07:00</published><updated>2009-06-04T12:02:53.245-07:00</updated><title type='text'>What’s wrong with this code?</title><content type='html'>&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SigaFfXaTwI/AAAAAAAAA58/QaNjZVsqaek/s1600-h/image%5B4%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SigaWFWQB8I/AAAAAAAAA6A/iIruXV6Hjq8/image_thumb%5B2%5D.png?imgmax=800" width="592" height="194" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;The breakpoint at line 18 never hits. &lt;/p&gt;  &lt;p&gt;This is a really silly bug :D. &lt;/p&gt;  &lt;p&gt;Leave comments if you know what is wrong.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4712137523718038701?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4712137523718038701/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4712137523718038701' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4712137523718038701'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4712137523718038701'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/whats-wrong-with-this-code.html' title='What’s wrong with this code?'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_Oy9HuksgrdU/SigaWFWQB8I/AAAAAAAAA6A/iIruXV6Hjq8/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-218623512566913056</id><published>2009-06-04T11:56:00.001-07:00</published><updated>2009-06-04T11:56:45.492-07:00</updated><title type='text'>.NET Funda : MemoryStream ToArray() vs. GetBuffer()</title><content type='html'>&lt;p&gt;Look at the following program.&lt;/p&gt;  &lt;pre class="csharp" name="code"&gt; class Program&lt;br /&gt;    {&lt;br /&gt;        static void Main(string[] args)&lt;br /&gt;        {&lt;br /&gt;            MemoryStream ms = new MemoryStream();&lt;br /&gt;            //write 10 bytes to the memory stream.&lt;br /&gt;            for (byte i = 65; i &amp;lt; 75; i++)&lt;br /&gt;                ms.WriteByte(i);&lt;br /&gt;&lt;br /&gt;            System.Console.WriteLine(&amp;quot;MemoryStream.GetBuffer() : {0}&amp;quot;,&lt;br /&gt;                                        ms.GetBuffer().Length);&lt;br /&gt;            System.Console.WriteLine(&amp;quot;MemoryStream.ToArray() : {0}&amp;quot;,&lt;br /&gt;                                        ms.ToArray().Length);&lt;br /&gt;            &lt;br /&gt;            System.Console.WriteLine(&amp;quot;GetBuffer() BytesToString : {0}&amp;quot;,&lt;br /&gt;                                        FromBytesToString(ms.GetBuffer()));&lt;br /&gt;            System.Console.WriteLine(&amp;quot;ToArray() BytesToString : {0}&amp;quot;,&lt;br /&gt;                                        FromBytesToString(ms.ToArray()));&lt;br /&gt;&lt;br /&gt;            ms.Close();&lt;br /&gt;            System.Console.WriteLine(&amp;quot;GetBuffer() BytesToString : {0}&amp;quot;,&lt;br /&gt;                                        FromBytesToString(ms.GetBuffer()));&lt;br /&gt;            System.Console.WriteLine(&amp;quot;ToArray() BytesToString {0}&amp;quot;,&lt;br /&gt;                                        FromBytesToString(ms.ToArray()));&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;        public static string FromBytesToString(byte[] b)&lt;br /&gt;        {&lt;br /&gt;            return ASCIIEncoding.Default.GetString(b);&lt;br /&gt;        }&lt;br /&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In the above code, we use a MemoryStream and write 10 bytes (from A(65) to J(74)).&amp;#160; Running the program gives the following result.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SigY4fjVuoI/AAAAAAAAA50/ZzJVf2qFhFU/s1600-h/image%5B6%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SigY6ZGvJ4I/AAAAAAAAA54/f4rh8StOq50/image_thumb%5B4%5D.png?imgmax=800" width="571" height="289" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The first two print statements displays the length of the byte[] array returned by both GetBuffer() and ToArray(). Now, both these methods returns the byte[] written to the memory stream but &lt;strong&gt;&lt;u&gt;the difference is that GetBuffer() returns the allocated byte buffer used by the memory stream and this also includes the unused bytes where as ToArray() returns only the used bytes from the buffer. &lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Since a memory stream is initialized with a byte array of size 256, even though only 10 bytes have been written to the stream, the buffer returned is of size 256 (of which only 10 bytes are used). Printing the Bytes to string, thus displays a long series of empty lines where as ToArray() returns only 10 bytes that were used and displays the string exactly of size 10.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Note that both these methods work even when the stream is closed (demonstrated by the last two print lines in the code above). &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The usage becomes important especially when you are trying to perform in-memory deserialization of some object from the memory stream for reasons like the binary data would be totally different from what was written actually, when using&amp;#160; GetBuffer().&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-218623512566913056?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/218623512566913056/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=218623512566913056' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/218623512566913056'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/218623512566913056'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/net-funda-memorystream-toarray-vs.html' title='.NET Funda : MemoryStream ToArray() vs. GetBuffer()'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_Oy9HuksgrdU/SigY6ZGvJ4I/AAAAAAAAA54/f4rh8StOq50/s72-c/image_thumb%5B4%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1762466272450199032</id><published>2009-06-02T17:01:00.001-07:00</published><updated>2009-06-02T17:06:25.130-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF Forum Questions'/><title type='text'>WPF Databinding : Using CompositeCollection</title><content type='html'>&lt;p&gt;The goal is to have a ComboBox whose ItemsSource should bind to more than one collection. In order to this, we make use of CompositeCollection as shown below.&lt;/p&gt;  &lt;div&gt;XAML&lt;/div&gt;  &lt;pre class="xml" name="code"&gt;&lt;p&gt;&amp;lt;StackPanel&amp;gt; &lt;br /&gt;  &amp;lt;ComboBox Name=&amp;quot;cb&amp;quot; ItemsSource=&amp;quot;{Binding MoreThanOneCollection}&amp;quot;&amp;gt; &lt;br /&gt; &amp;lt;/ComboBox&amp;gt; &lt;br /&gt; &amp;lt;/StackPanel&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;div&gt;Code-behind&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;pre name="code" class="vb.net"&gt;&lt;br /&gt;&lt;br /&gt;Private _moreThanOneCollection As New CompositeCollection&lt;br /&gt;&lt;br /&gt;    Public Property MoreThanOneCollection() As CompositeCollection&lt;br /&gt;        Get&lt;br /&gt;            Return _moreThanOneCollection&lt;br /&gt;        End Get&lt;br /&gt;        Set(ByVal value As CompositeCollection)&lt;br /&gt;            _moreThanOneCollection = value&lt;br /&gt;        End Set&lt;br /&gt;    End Property&lt;br /&gt;&lt;br /&gt;    Private Sub Window_Loaded(ByVal sender As System.Object, _&lt;br /&gt;                              ByVal e As System.Windows.RoutedEventArgs)&lt;br /&gt;        Me.DataContext = Me 'set the datacontext&lt;br /&gt;        BindData()&lt;br /&gt;        BindMoreData()&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Sub BindMoreData()&lt;br /&gt;        Dim data2 As New CollectionContainer&lt;br /&gt;        data2.Collection = GetData().Reverse()&lt;br /&gt;        'another set of data, just for the heck of it&lt;br /&gt;        MoreThanOneCollection.Insert(0, data2)&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;    Sub BindData()&lt;br /&gt;        Dim container = New CollectionContainer&lt;br /&gt;        container.Collection = GetData() ' the first data&lt;br /&gt;        MoreThanOneCollection.Add(container)&lt;br /&gt;    End Sub&lt;br /&gt;&lt;br /&gt;    Function GetData() As IEnumerable(Of String)&lt;br /&gt;        Dim x As New ObservableCollection(Of String)&lt;br /&gt;        x.Add(&amp;quot;Item 1&amp;quot;)&lt;br /&gt;        x.Add(&amp;quot;Item 2&amp;quot;)&lt;br /&gt;        x.Add(&amp;quot;Item 3&amp;quot;)&lt;br /&gt;        Return x&lt;br /&gt;    End Function&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Just for practise purpose, I thought I would create the composite collection in code. This can also be done in XAML. &lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1762466272450199032?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1762466272450199032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1762466272450199032' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1762466272450199032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1762466272450199032'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/wpf-databinding-using.html' title='WPF Databinding : Using CompositeCollection'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-5133764753874692007</id><published>2009-06-02T10:17:00.000-07:00</published><updated>2009-06-02T17:06:25.130-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF Forum Questions'/><title type='text'>Loading BitmapImage from disk</title><content type='html'>While loading image in XAML is pretty  easy (use &amp;lt;Image Source="xx.jpg"/&amp;gt;), it is not so straight forward to load an ImageSource from a file. (I always forget how to do this). So here is the code which might help you all. I have also specified some commented code which can be used to get thumbnails out of the image and other options like caching, etc.&lt;br /&gt;&lt;pre class="c-sharp" name="code"&gt;&lt;br /&gt;ImageSource LoadImage(string filePath)&lt;br /&gt;        {&lt;br /&gt;            BitmapImage img = new BitmapImage();&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;                img.BeginInit();&lt;br /&gt;                img.UriSource = new Uri(filePath, UriKind.RelativeOrAbsolute);&lt;br /&gt;                img.CacheOption = BitmapCacheOption.OnLoad;&lt;br /&gt;                //img.CreateOptions = BitmapCreateOptions.DelayCreation;&lt;br /&gt;                img.DecodePixelWidth = 50;&lt;br /&gt;                //img.DecodePixelHeight = 200;&lt;br /&gt;                img.EndInit();&lt;br /&gt;            }&lt;br /&gt;&lt;br /&gt;            catch&lt;br /&gt;            {&lt;br /&gt;            }&lt;br /&gt;            return img;&lt;br /&gt;&lt;br /&gt;        }&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;By the way, I have at last set up SyntaxHighlighter for my blog! this is sweet. Thanks to &lt;a href="http://heisencoder.net/2009/01/adding-syntax-highlighting-to-blogger.html"&gt;this post&lt;/a&gt; for the instructions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-5133764753874692007?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/5133764753874692007/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=5133764753874692007' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5133764753874692007'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5133764753874692007'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/imagesource-loadimagestring-filepath.html' title='Loading BitmapImage from disk'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-1516122457447073711</id><published>2009-06-01T18:11:00.001-07:00</published><updated>2009-06-02T17:06:14.409-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>Real world – really simple Composite WPF application for Twitter</title><content type='html'>&lt;p&gt;Well, the name says it all. In this post, I would like to talk about how to implement a very basic (emphasis on very) twitter application as a Composite WPF application. I would like to demonstrate as many concepts in PRISM (Composite WPF) as possible and the following is the list that I am looking at.&lt;/p&gt;  &lt;p&gt;1. Getting hold of CAL libraries.    &lt;br /&gt;2. Setting up the WPF shell – working with Bootstrapper.     &lt;br /&gt;3. Working with Regions – simple and nested regions.     &lt;br /&gt;4. Implementing modules and integrating them on to the defined.     &lt;br /&gt;5. Using Commanding framework in the application.     &lt;br /&gt;6. Communication between the modules – the PRISM way.     &lt;br /&gt;7. &lt;strong&gt;&lt;u&gt;Last but not the least, we will be using the excellent Tweet#. &lt;a href="http://code.google.com/p/tweetsharp/downloads/list"&gt;Get the library from here&lt;/a&gt;.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Side-concepts about WPF includes MVVM (as I understand, I am not a guru), defining templates for ListView, etc.&lt;/p&gt;  &lt;p&gt;For those expecting wonders, this app does not do anything but implement what &lt;a href="http://search.twitter.com"&gt;http://search.twitter.com&lt;/a&gt; does. Give in a search term and it returns you the results. Screenshot shown below. If you like it, then you can proceed and read this long story, otherwise thanks for visiting. &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiR7_S0B9OI/AAAAAAAAA4c/PhNF7QpmroM/s1600-h/image%5B4%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/SiR7_7R3i6I/AAAAAAAAA4g/48SLV1rceS0/image_thumb%5B2%5D.png?imgmax=800" width="591" height="427" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Getting the Composite Application Library for WPF &amp;amp; Silverlight&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;I would not be stressing much on this, just a walkthrough. The composite application library does not ship binaries and ships source instead.&lt;/p&gt;  &lt;p&gt;1. Download the latest CA L from &lt;a href="http://compositewpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=23450"&gt;codeplex&lt;/a&gt;. The actual download site is on the Microsoft Servers – &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=fa07e1ce-ca3f-4b9b-a21b-e3fa10d013dd&amp;amp;DisplayLang=en"&gt;direct download link&lt;/a&gt;. Extract/Install the CAL.&lt;/p&gt;  &lt;p&gt;2. I placed the extracted files in Development\prism folder. Inside this folder, you see a CAL folder which contains the VS solution files.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiR7_6RkXXI/AAAAAAAAA4k/0-vIl_VFUSU/s1600-h/image%5B7%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SiR8AX5cu6I/AAAAAAAAA4o/CtUWf3dVSUs/image_thumb%5B3%5D.png?imgmax=800" width="244" height="130" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;3. Open the CompositeApplicationLibrary_Desktop.sln in Visual Studio 2008 and build the solution. (I built mine with Debug configuration).&lt;/p&gt;  &lt;p&gt;4. Now go into Desktop folder and you see a whole bunch of Composite.* folders. Now the libraries that we would use are the output of the projects that you see in here. To save time, instead of going into individual folders, you can directly go into &lt;strong&gt;&lt;u&gt;Composite.UnityExtensions&lt;/u&gt;&lt;/strong&gt; folder/bin/&amp;lt;Debug or Release&amp;gt;. You should see the following libraries (assuming your build was successful).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiR8AgZNryI/AAAAAAAAA4s/aL3G641p_xM/s1600-h/image%5B10%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiR8AwKBjbI/AAAAAAAAA4w/owV8bwMDM1w/image_thumb%5B4%5D.png?imgmax=800" width="244" height="221" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Copy both the DLL and PDB files into a separate folder of your choice. I typically copy mine into a “libraries” folder inside the project that I am working on. It is from here that I add references. I also copied the Tweet# libraries (Dimebrain.TweetSharp.dll and NewtonSoft.Json.dll) into the same folder.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiR8BPq2aiI/AAAAAAAAA40/AEFWIsfyH0Q/s1600-h/image%5B13%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SiR8BaH2EMI/AAAAAAAAA44/jaDBwDoqYVU/image_thumb%5B5%5D.png?imgmax=800" width="244" height="150" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now lets get on with the development.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;STEP 1 : The WPF Shell&lt;/u&gt;&lt;/strong&gt;.&lt;/p&gt;  &lt;p&gt;1. Create a new WPF application project and name it as you want, I named mine as &lt;strong&gt;&lt;u&gt;tru-twitter&lt;/u&gt;&lt;/strong&gt;. &lt;/p&gt;  &lt;p&gt;Add references to the Composite libraries that we saved previously. Some prefer not to build the libraries separately. Instead they add the CAL solution using the project linker shipped along with CAL distribution. But I like to keep my projects simple.&lt;/p&gt;  &lt;p&gt;2. Now, all composite applications are hosted inside a shell. This shell would be implemented by using the simple steps described next. The shell is created via a bootstrapper which shows the shell (no magic, a shell is just a window which acts as the container for our application) and does other ground-work some of which include setting up the Inversion Of Control Container (Unity is the default with composite app library and this can be replaced, which is a different topic altogether), configures modules, etc. &lt;/p&gt;  &lt;p&gt;3. So we need a bootstrapper. For this, add a new file to your project and name it as Bootstrapper.cs. Make your Bootstrapper class public sealed (which I like to do since sealed classes, i think, are more optimization-friendly and design friendly as well). The bootstrapper class should extend the &lt;strong&gt;&lt;u&gt;UnityBootstrapper&lt;/u&gt;&lt;/strong&gt; class. You can right click on the UnityBootstrapper and resolve the usages. Then you have to override “CreateShell()” method to say the least. Look at the code below which is pretty much self-explanatory.&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; Bootstrapper : UnityBootstrapper&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {     &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;readonly&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; ModulePath = Settings.&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                            Default.&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                            Properties[&lt;span style="color: #006080"&gt;&amp;quot;Modules&amp;quot;&lt;/span&gt;].&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                            DefaultValue.ToString();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// The CreateShell method instantiates the shell window.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// It is also responsible to show the window.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// &amp;lt;returns&amp;gt;The shell that was shown.&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; System.Windows.DependencyObject CreateShell()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//get the shell using IOC.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var shell = Container.Resolve&amp;lt;Shell&amp;gt;();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            shell.Show();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//RegisterGlobalServices();&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;return&lt;/span&gt; shell;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// Configure what kind of Module Catalog you would be using.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// This application uses the DirectoryModuleCatalog.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// All modules placed within ModulePath are loaded.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;/// &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; IModuleCatalog GetModuleCatalog()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; DirectoryModuleCatalog()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                ModulePath = ModulePath&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            };&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The Window1.xaml has been renamed to Shell.xaml. Note that using Refactor option within Visual Studio to rename the class would be the best way to go since it can track all the places where Window1 was used.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;4. Now open the App.xaml in XAML View and remove the “StartupUri” attribute. You have seen that the boot strapper takes care of showing the window. Now inside App.xaml.cs, modify the &lt;strong&gt;OnStartup()&lt;/strong&gt; as shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&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;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; OnStartup(StartupEventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;// let the base class do whatever it does.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;base&lt;/span&gt;.OnStartup(e);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//create the bootstrapper&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var bs = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; Bootstrapper();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//call the Run() method on the bootstrapper.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            bs.Run();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The bootstrapper is triggered by the Run() method which is called from the OnStartup. The bootstrapper then does a lot of things (i dont know the list exactly but it configures your container, your module catalog loader and then invokes CreateShell method in which you show the window). Thus, on startup, the shell is created and is shown. Run the application to see it works without any issues. If you are unable to see the window, then there might be two issues – &lt;strong&gt;&lt;em&gt;not calling the method Run() on the Bootstrapper or failing to invoke Show() method in the CreateShell().&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;5. Now we have the shell up and running. What ever the shell hosts (user controls), they are to be implemented as a modules. Before that lets tell the shell where to put the modules.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;6. To do that shell should have Regions defined. Any container that contains a region is managed by the global “RegionManager” which takes helps in adding/removing views. For our application, we have one region within the shell. To define a region, open Shell.xaml in XAML view. Since there would be only one view, we define a ContentControl and give it a region name as shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Window&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;tru.twitter.Shell&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;xmlns:cal&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;xmlns:helpers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:tru.twitter.common.Helpers;assembly=tru.twitter.common&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;Title&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;tru-Twitter!&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        &lt;span style="color: #ff0000"&gt;WindowState&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Maximized&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;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 helpers:RegionNames.SearchRegion}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Window&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now you can notice two additional xml namespaces being added to the Window element. The “cal” namespaces allows us to access members of the “Microsoft.Practices.Composite.Presentation.Regions” namespace where as the “helpers” namespace refers to a custom library (just a class library) which contains my RegionNames. I prefer to have all my region names stored in a separate class and exposed as static members such that changes to the names would be rather easy and prevents us from hard-coding at several places.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;The above XAML shows setting the RegionName (an attached property) and also shows how to access static members of the region names class.&lt;/u&gt;&lt;/strong&gt;&lt;br /&gt;&lt;br /&gt;  &lt;br /&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;7. Now that the region name is ready, let us add a new module to our project. Add a new Class library project to your existing solution. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;em&gt;I named it as “tru.twitter.search” which is not a good choice. I often name my module projects with “modules” in the name such that it tells me that this project is a module and not to be referenced directly in any other project. The modules are great since they are completely decoupled and I could replace the modules completely as I wish. The project structure should now include the shell project, search module project and the library project(tru.twitter.common, which contains code that is shared across all the projects, like the region names wrapper, services that I use, etc).&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;8. Modify the project properties of the module (right click =&amp;gt; properties) to set the build output directory to where the ModulePath property points to in the Bootstrapper.cs file. Mine points to the “Modules” folder within the shell output directory. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiR8B68XGKI/AAAAAAAAA48/EPziJaO6QnI/s1600-h/image%5B22%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SiR8CSo---I/AAAAAAAAA5A/i7yjlSh_5Cc/image_thumb%5B12%5D.png?imgmax=800" width="552" height="405" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;For any module that you add, you should be doing this. Also note that the setting depends on the current build configuration. If you change the configuration from debug to release, you have to reset the path again.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;9. Each module should have a module initializer class which implements the “IModule” interface. So, first of to resolve IModule interface, add all the composite library dll that were in the libraries folder. Then select these dll in the references and go to the properties. Set “Copy To Output” as false. These libraries are already being used by the shell and they would be reused by the modules are runtime.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;10. The module initializer class – SearchModule should implement IModule interface and should define the “Initialize()” method. Since this module has UI elements which should be loaded into the regions, the module should have access to the Region Manager. The module also can use the IOC container to resolve objects which keeps the design much simpler, so it should also have access to the IOC container. Thus the module constructor would have the region manager and container as parameters. The module loader resolves this module during which the registered container and region manager are automatically passed to the constructor.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiR8C8i-w0I/AAAAAAAAA5E/QZdPje-1O_w/s1600-h/image%5B27%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiR8EEcoQNI/AAAAAAAAA5I/JSO05s0gmiM/image_thumb%5B15%5D.png?imgmax=800" width="589" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You can notice that my Initialize method registers services and views. So add the stubs for these two methods. Also make sure you add private fields for IRegionManager and IUnityContainer. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;11. Let us test the set up so far. Build the solution and verify if the module is copied where it was supposed to be (remember we set the project output path earlier). Now, place a breakpoint at first line of constructor and inside the Initialize() method and run the application. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;When the constructor breakpoint is hit, you should see both “rm” and “ctr” to not be null and instead they would be instances of IRegionManager and IUnityContainer. These instances are singleton and the same are used across the application.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;After the constructor is hit, the Initialize() method should also be hit.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;12. Now in the RegisterViews() method, we create the view we want to and add it to the region manager. Let us say that we have one single view called “SearchView” which should be loaded into the SearchRegion that was defined in the Shell.xaml. The RegisterViews() method should then be implemented as shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RegisterViews()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            LoadSearchRegion();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; LoadSearchRegion()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var searchView = _container.Resolve&amp;lt;SearchView&amp;gt;();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var searchRegion = _regionManager.Regions[RegionNames.SearchRegion];&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            searchRegion.Add(searchView);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            searchRegion.Activate(searchView);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//The search view region consists of SearchInput view and a results view.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//By default only search input region is loaded.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//Search Results would be loaded on demand - when search button is pressed.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            LoadSearchInputRegion();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;We shall get back to the LoadSearchInputRegion() shortly. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To avoid confusion, look at the screenshot below. The whole UI you see is the SearchView loaded into the Window (shell). The SearchView has two regions – Search Input Region (contains the SearchInputView) and the search results region.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;When the application starts, only the search input view would be shown. Thus you can only see the LoadSearchInputRegion() method being called inside the LoadSearchRegion(). &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;When the user presses the search button, the results are retrieved and the results view would be added. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiR8E9RNF3I/AAAAAAAAA5M/eqkFjLH5c4o/s1600-h/image%5B33%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiR8FXqr0AI/AAAAAAAAA5Q/Y3fgLqNjVxw/image_thumb%5B19%5D.png?imgmax=800" width="524" height="464" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The search input region is marked in yellow and the search results view is marked in blue. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;13. Now let us implement the SearchView (the one which contains both the search input view at the top and search results at the bottom). Add a new WPF user control and name it as SearchView.xaml. Modify the XAML as shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;UserControl&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Class&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;tru.twitter.search.Views.SearchView&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;             &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;             &lt;span style="color: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;             &lt;span style="color: #ff0000"&gt;xmlns:cal&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:Microsoft.Practices.Composite.Presentation.Regions;assembly=Microsoft.Practices.Composite.Presentation&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;             &lt;span style="color: #ff0000"&gt;xmlns:helpers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:tru.twitter.common.Helpers;assembly=tru.twitter.common&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;RowDefinition&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Height&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;RowDefinition&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;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 helpers:RegionNames.SearchInputRegion}&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        &lt;span style="color: #ff0000"&gt;Grid&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;Row&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;0&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;TabControl&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 helpers:RegionNames.SearchResultsRegion}&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    &lt;span style="color: #ff0000"&gt;Grid&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;Row&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;TabControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;UserControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;It has two rows in the grid – one for input region and one for results region. We just defined the regions and the views are loaded into these regions when the Add(view) is invoked on the region manager and then the views appear when Activate(view) is invoked. While the input region is simple, just like the one that we defined in the shell. Note that even though the regions in search view appear as if there are regions inside the region (SearchRegion in the shell), we would still be using the same region manager but nothing any fancy. The region manager is global and it figures out the regions, however nested they are.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;We have already looked at ContentControl region. Now if you notice the search results region is defined as a TabControl. This is another control whose &lt;strong&gt;RegionAdapter&lt;/strong&gt; is already implemented in the CAL. Another control with ready to use region adapter is the ItemsControl. (which we would not be looking at today).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;TabControl&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 helpers:RegionNames.SearchResultsRegion}&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    &lt;span style="color: #ff0000"&gt;Grid&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;Row&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;TabControl&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You have already observed that the same RegionNames class is being used even in this project – therefore you should not forget to add reference to the tru.twitter.common library and set the reference property “Copy to output” to false.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;14. We now have two more regions for which views has to be implemented. So first let us implement the SearchInputView which sits in the SearchInputRegion. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;15. Add a new user control called SearchInputView.xaml. Also add a new C# class called SearchInputViewModel. Those familiar with MVVM can see that I am trying to burn my hands with MVVM. One advice up here is to place all views inside a “Views” folder and View models inside “ViewModels” folder within the project.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiR8FkEm1nI/AAAAAAAAA5U/uop18RDpuTk/s1600-h/image%5B36%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SiR8GDDryII/AAAAAAAAA5Y/kCSw9RO8pLY/image_thumb%5B20%5D.png?imgmax=800" width="238" height="244" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Let us first look at LoadSearchInputRegion() implementation inside the SearchModule.cs&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; LoadSearchInputRegion()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;       {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           var searchInputView = _container.Resolve&amp;lt;SearchInputViewModel&amp;gt;().View;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           var searchInputRegion = _regionManager.Regions[RegionNames.SearchInputRegion];&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           searchInputRegion.Add(searchInputView);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;           searchInputRegion.Activate(searchInputView);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;       }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Notice that it is the ViewModel that is being resolved first and the view is obtained via the “View” property. The region is obtained using the regionManager instance that was obtained via the constructor and passing the region name to the “Regions” property.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So first of all, the ViewModel should have a “View” property. The ViewModel also should provide the properties which the View binds to. And for the data binding to auto-manage changes between the View and the ViewModel properties, the ViewModel should implement INotifyProperty changed interface. Thus far, we can deduce that any viewmodel should implement a view property as well as the INotifyPropertyChanged interface. So we place this common functionality inside a separate class called “ViewModelBase” (place it in the commons library project).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;abstract&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; ViewModelBase&amp;lt;T&amp;gt; : INotifyPropertyChanged &lt;span style="color: #0000ff"&gt;where&lt;/span&gt; T : UserControl&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//View is of type T, which essentially is a UserControl.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; T View { get; set; }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; ViewModelBase(T view)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;this&lt;/span&gt;.View = view;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            View.DataContext = &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;protected&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RaisePropertyChanged(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; propThatChanged)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;if&lt;/span&gt; (PropertyChanged != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                PropertyChanged(&lt;span style="color: #0000ff"&gt;this&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; PropertyChangedEventArgs(propThatChanged));&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;event&lt;/span&gt; PropertyChangedEventHandler PropertyChanged;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The abstract class defines a parameterized constructor which takes in the instance of the View. This instance would be automatically created by the Container#Resolve&amp;lt;&amp;gt;() method. But this also tells us that the ViewModel implementation should invoke this constructor. Let us look at the SearchInputViewModel class.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SearchInputViewModel : ViewModelBase&amp;lt;SearchInputView&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; SearchInputViewModel(SearchInputView view)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;base&lt;/span&gt;(view)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            InitializeCommands();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; _search;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; Search&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _search; }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            set&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _search = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                RaisePropertyChanged(&lt;span style="color: #006080"&gt;&amp;quot;Search&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The “Search” property should be bound to the textbox which accepts the user input. The XAML for SearchInputView is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;ColumnDefinition&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;*&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;ColumnDefinition&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;70&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;TextBox&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;#AABBCCDD&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;Foreground&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;FontFamily&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Verdana&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;FontSize&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;24&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;Text&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Search}&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;Width&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Auto&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;VerticalContentAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Center&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Stretch&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Button&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Grid&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;Column&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;1&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;TextBlock&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;FontFamily&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Impact&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;TextBlock&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;FontSize&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;15&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;Foreground&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AntiqueWhite&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Padding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Search&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Stretch&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;               &lt;span style="color: #ff0000"&gt;VerticalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Stretch&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Button&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Grid&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Again the XAML is simple and straight forward.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;16. &lt;strong&gt;&lt;u&gt;Using Commanding in Composite WPF apps.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The rule for proper implementation of the MVVM pattern is to keep the code-behind for the view with no code at all. The interaction between the ViewModel and the View would be via data binding (which we used in the Textbox which binds to Search property in the ViewModel) and the user events like button click should be implemented via &amp;quot;&lt;strong&gt;Commanding”&lt;/strong&gt;. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To implement command, modify the button XAML in the search input view as shown.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiR8GPO8vmI/AAAAAAAAA5c/JILbq6A3X3Y/s1600-h/image%5B40%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SiR8GVIUIFI/AAAAAAAAA5g/6cCcJIPyPq8/image_thumb%5B22%5D.png?imgmax=800" width="528" height="207" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The DataContext for this view was already set in the ViewModelBase class. So the “SearchCommand” would be looked in the current ViewModel which is SearchInputViewModel. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To implement commanding, add a new property of type DelegateCommand&amp;lt;object&amp;gt;. Then the command is instantiated in the constructor. The modified ViewModel is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiR8G7D7ZgI/AAAAAAAAA5k/ey2CNyMpu8A/s1600-h/image%5B47%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SiR8HKPxPVI/AAAAAAAAA5o/A0AFstHOeBs/image_thumb%5B27%5D.png?imgmax=800" width="533" height="340" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The DelegateCommand&amp;lt;object&amp;gt; constructor takes in two delegates one which is used to determine if the command can be executed and one which is invoked when the command is executed. The above code shows that the command is only executed when the “Search” property has some input entered. (see second parameter). When the command is executed, the “search service” is used executed. Notice ethat the constructor is modified to include a reference to the search service that would be used. We will get there in a while. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Note that the instance of the search service is also resolved using the IOC container, which by itself is sweet! But the container has to know which implementation should be used for the ISearchService, so we register the service. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;17. &lt;strong&gt;&lt;u&gt;The Twitter Search Service – Publishing events in Composite WPF world.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The twitter service is something that we would be using throughout the application and therefore it is like a global service. So we place the implementation in the common library where as register the service in the Bootstrapper as shown.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; RegisterGlobalServices()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            Container.RegisterType&amp;lt;ISearchService,TwitterSearchService&amp;gt;(&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;new&lt;/span&gt; ContainerControlledLifetimeManager()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                                   );&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The RegisterGlobalServices() method is invoked in the CreateShell() method ( which was previously uncommented).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Following shows the ISearchService implementation.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; TwitterSearchService : tru.twitter.common.Services.ISearchService&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; EventAggregator _eventAgg;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; TwitterSearchService(EventAggregator eventAggregator)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;this&lt;/span&gt;._eventAgg = eventAggregator;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; ExecuteSearch(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; searchKey)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//get twitter results&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var req = FluentTwitter.CreateRequest()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         .Search()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         .Query()&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         .Containing(searchKey)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                         .AsJson();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            req.CallbackTo((s, e) =&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                var result = e.Response.AsSearchResult();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _eventAgg.GetEvent&amp;lt;SearchCompletedEvent&amp;gt;().Publish(result);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }).RequestAsync();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;In the ExecuteSearch() method you can notice that once the result from Twitter is obtained, the result is published as an event using the EventAggregator provided by the composite application library. &lt;strong&gt;Note that this is not the best implementation. Because the service is now dependent on the CAL which makes it less decoupled. This is one area where the code has to be refactored (we will look into that in the future articles).&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The EventAggregator can publish an event. When an event is published, those who have “subscribed” to the event would be notified. Let us first look at the SearchCompletedEvent which is a C# class that just derives from CompositePresentationEvent&amp;lt;&amp;gt;. Since the result is an instance of “TwitterSearchResult”, it is passed to the generic type. The implementation is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;class&lt;/span&gt; SearchCompletedEvent : CompositePresentationEvent&amp;lt;TwitterSearchResult&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now we have a service that when executed and completed the search raises the SearchCompletedEvent. So we should have a subscriber which can be notified when the event is published. The subscriber would then create the SearchResultsView and add the view to the search results region. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;18. &lt;strong&gt;&lt;u&gt;Subscribing the events in composite WPF.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now we shall look at how subscriber should be implemented and also look at how views are loaded into regions on demand.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiR8Hnbzi4I/AAAAAAAAA5s/bSdkLCK6780/s1600-h/image%5B52%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/SiR8H3vHSFI/AAAAAAAAA5w/P5vJ7ePbDNY/image_thumb%5B30%5D.png?imgmax=800" width="545" height="318" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Go to SearchModule.cs and modify the RegisterServices() method as shown above. In this method we obtain the instance of the event aggregator with the help IOC container. Then we obtain the event using GetEvent&amp;lt;event type&amp;gt; method on the event aggregator. Then using the Subscribe() method we subscribe to the event. When the search completed event is published, the Action (as a lambda) passed to the subscribe method is invoked. We also specify that the event subscription action would be invoked at the UIThread. Look into the documentation for more information on this. In this method we simply load the search results tab view. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Note that the SearchResultsTabView is just a user control like any other one. But because the SearchResults region was a tab control, the TabControlRegionAdapater comes into play and automatically adds a TabViewItem to the TabControl and sets the content to the SearchResultsView. The TabControlRegionAdapter is already implemented in the CAL and we need not worry about it. The LoadSearchResultsTabView(result) is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; LoadSearchResultsTabView(TwitterSearchResult res)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;{&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//get the view model&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var searchResultsVM = _container.Resolve&amp;lt;SearchResultsViewModel&amp;gt;();&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//set the result to the &amp;quot;Model&amp;quot; property of the view model.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            searchResultsVM.Model = res;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//get the View using the View property.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var searchResultsView = searchResultsVM.View;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;//get the region, add and activate.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            var searchResultsRegion = _regionManager.Regions[RegionNames.SearchResultsRegion];&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            searchResultsRegion.Add(searchResultsView);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            searchResultsRegion.Activate(searchResultsView);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;}&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Please read the comments for the code to make more sense.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;19. Implementing the SearchResultsView/ViewModel.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Add a new C# class called “SearchResultsViewModel”. This class should derive from ViewModelBase which takes in SearchResultsView as the generic parameter. The ViewModel should pass in the View to the base constructor and then also define properties like “Model” and “SearchedFor”. The whole implementation is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;class&lt;/span&gt; SearchResultsViewModel : ViewModelBase&amp;lt;SearchResultsView&amp;gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; SearchResultsViewModel(SearchResultsView view)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;base&lt;/span&gt;(view)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; TwitterSearchResult _model;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; TwitterSearchResult Model&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            get { &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; _model; }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            set&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _model = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;base&lt;/span&gt;.RaisePropertyChanged(&lt;span style="color: #006080"&gt;&amp;quot;Model&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;private&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; _searchedFor;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; SearchedFor&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            get&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;if&lt;/span&gt; (_searchedFor == &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;)&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                    _searchedFor = Model.Query;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;return&lt;/span&gt; _searchedFor;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            set&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                _searchedFor = &lt;span style="color: #0000ff"&gt;value&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                RaisePropertyChanged(&lt;span style="color: #006080"&gt;&amp;quot;SearchedFor&amp;quot;&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;&amp;#160;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;    }&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Add the SearchResultsView as new WPF UserControl. The XAML is simple – display the list of “Statuses”, a property that is exposed in the “TwitterSearchResult” class.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;&lt;br /&gt;  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;ListView&lt;/span&gt; &lt;span style="color: #ff0000"&gt;DataContext&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Model}&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: #ff0000"&gt;ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Path=Statuses}&amp;quot;&lt;/span&gt; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: #ff0000"&gt;HorizontalContentAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Stretch&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: #ff0000"&gt;ScrollViewer&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;CanContentScroll&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;              &lt;span style="color: #ff0000"&gt;ScrollViewer&lt;/span&gt;.&lt;span style="color: #ff0000"&gt;VerticalScrollBarVisibility&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Visible&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;ListView.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Border&lt;/span&gt; &lt;span style="color: #ff0000"&gt;CornerRadius&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;AntiqueWhite&amp;quot;&lt;/span&gt; &lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        &lt;span style="color: #ff0000"&gt;HorizontalAlignment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Stretch&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        &lt;span style="color: #ff0000"&gt;Margin&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"&gt;                        &lt;span style="color: #ff0000"&gt;Padding&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;5&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Border.Effect&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;DropShadowEffect&lt;/span&gt; &lt;span style="color: #ff0000"&gt;BlurRadius&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;3&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Border.Effect&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Label&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Id}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Label&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Content&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{Binding Text}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;Border&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;DataTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;ListView.ItemTemplate&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;br /&gt;&lt;br /&gt;    &lt;pre style="border-bottom-style: none; text-align: left; 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: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; 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;ListView&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;!--CRLF--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Observe the ListView’s DataContext property has been set to the Model. (The user control’s DataContext property is already set to the ViewModel in the ViewModelBase). The ItemsSource property is set to “Statuses”, which is defined as a property inside “Model”. To enable scrolling, the ScrollViewer.XXX properties are set.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The ListView then defines an ItemTemplate, which tells the WPF engine on how each item (each status, of type TwitterSearchStatus) is rendered. It is the “template” for each TwitterSearchStatus item. For cosmetic reasons, I have included a Border with a DropShadowEffect applied. Inside the border is a stack panel which displays the Id of the status and the status text.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;u&gt;&lt;strong&gt;SOURCE CODE&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Well, what I promised at the start of the article, I have covered the most. &lt;a href="http://cid-b3c743d57f70a9ed.skydrive.live.com/self.aspx/Public/tru.twitter.zip"&gt;The source for the application is available for download at my skydrive.&lt;/a&gt; I have not included the dependency libraries (CAL, Tweet#) since I am not sure about their licensing. License?? Use the code as you like, you can do whatever you feel like. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;What next&lt;/u&gt;?&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;1. The current implementation, though adds a new TabItem for each search, it does not display the tab header. The tab header should show the “SearchedFor” property.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;2. As you type in the search, the “Search” button is not enabled until the search is tabbed out. But the ideal implementation would be when the user enters the first character, the button should be enabled and when the user presses enter, search should be executed.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;3. Add the ability to auto refresh the results.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;4. Implement paging, as of now, the application displays only the first 15 status. &lt;a href="http://dimebrain.com/"&gt;TweetSharp library, by the guys from Dimebrain&lt;/a&gt; (they make wonderful mini-screencasts and of course this excellent library) returns the first 15 status in the first page and they provide excellent FluentInterface to twitter which makes it easy to retrieve the rest of the pages.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;5. Finally, implement a fully functional Twitter client – Yeah, Yet Another Twitter Client and I have some nice functionality ideas to implement which I would share in the future.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;6. Refactoring the code to make it well designed.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you have survived until this point, then I am doing a pretty good job at writing. I know its a long article and I have written the whole thing at one go ( after working for 8 hours, for a living). So kindly let me know for any bugs in this article.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-1516122457447073711?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/1516122457447073711/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=1516122457447073711' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1516122457447073711'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/1516122457447073711'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/real-world-really-simple-composite-wpf.html' title='Real world – really simple Composite WPF application for Twitter'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/SiR7_7R3i6I/AAAAAAAAA4g/48SLV1rceS0/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-5347642982510741263</id><published>2009-06-01T12:45:00.001-07:00</published><updated>2009-06-02T17:06:25.130-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><category scheme='http://www.blogger.com/atom/ns#' term='WPF Forum Questions'/><title type='text'>ListView/ListBox Selected Item Color – Active and Out of Focus</title><content type='html'>&lt;p&gt;The following snippet of XAML can help you set a fixed color scheme for a selected item in the list controls whether the control has focus or not.&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; font-size: 8pt;  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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;StackPanel&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Orientation&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Vertical&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Background&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;SeaGreen&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView.Resources&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;                        &lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SolidColorBrush&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Key&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{x:Static SystemColors.HighlightBrushKey}&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Color&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Red&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;SolidColorBrush&lt;/span&gt; &lt;span style="color: #ff0000"&gt;x:Key&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{x:Static SystemColors.ControlBrushKey}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;            &lt;/pre&gt;&lt;br /&gt;&lt;br /&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;                   Red&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;SolidColorBrush&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Style&lt;/span&gt; &lt;span style="color: #ff0000"&gt;TargetType&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;{x:Type ListViewItem}&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Trigger&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Property&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;IsSelected&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;True&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Setter&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Property&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Foreground&amp;quot;&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Value&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;Black&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Trigger&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Style.Triggers&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Style&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView.Resources&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListViewItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;String 1&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListViewItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListViewItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;String 2&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListViewItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListViewItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;String 3&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListViewItem&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Button&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;Button 1&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Button&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;     &lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;StackPanel&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-5347642982510741263?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/5347642982510741263/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=5347642982510741263' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5347642982510741263'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/5347642982510741263'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/listviewlistbox-selected-item-color.html' title='ListView/ListBox Selected Item Color – Active and Out of Focus'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-2679932570974941431</id><published>2009-06-01T07:23:00.001-07:00</published><updated>2009-06-02T17:06:14.410-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>Declaring Empty String in XAML</title><content type='html'>&lt;p&gt;Shown below is a code snippet which does not work.&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:System&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:System;assembly=mscorlib&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView.ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;coll:ArrayList&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;System:String&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;System:String&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;System:Int32&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;34&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;System:Int32&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;coll:ArrayList&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView.ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;One would notice the following error when the above XAML is parsed.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;Cannot create object of type “System.String”. CreateInstance failed, which can be caused by not having a public default constructor for ‘System.String’.&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The reason for this error is that the “System.String” class does not provide a default constructor and this disallows declaring empty string.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;What’s the fix?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&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;br /&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;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns:System&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;clr-namespace:System;assembly=mscorlib&amp;quot;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView.ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;coll:ArrayList&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #008000"&gt;&amp;lt;!-- notice empty string via usage of x:Static --&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;x:Static&lt;/span&gt; &lt;span style="color: #ff0000"&gt;Member&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;System:String.Empty&amp;quot;&lt;/span&gt; &lt;span style="color: #0000ff"&gt;/&amp;gt;&lt;/span&gt;          &lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;System:Int32&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;34&lt;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;System:Int32&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;coll:ArrayList&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;  &lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView.ItemsSource&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;ListView&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;/p&gt;&lt;br /&gt;Hope this helps.  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-2679932570974941431?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/2679932570974941431/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=2679932570974941431' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/2679932570974941431'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/2679932570974941431'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/06/declaring-empty-string-in-xaml.html' title='Declaring Empty String in XAML'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4316141622501779432</id><published>2009-05-29T13:54:00.001-07:00</published><updated>2009-05-29T13:54:32.086-07:00</updated><title type='text'>Using WCF + Silverlight 2 + PRISM : Gotchas</title><content type='html'>&lt;p&gt;In this entry, I would be talking about the issues that I have encountered when developing a Silverlight application structured with PRISM principles and that is driven by a WCF service. Some of the issues that I mention here are applicable even when making just Silverlight applications (like Data Binding Hello World!).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 1 : Working with Data Binding&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Shown below is the code snippet for startup xaml page – XAML code on the top and code behind at the bottom half.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLWL1Sa3I/AAAAAAAAA04/bIMatrK06tw/s1600-h/image17.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://lh3.ggpht.com/_Oy9HuksgrdU/SiBLWW0J_DI/AAAAAAAAA08/HNp8O_D8Ck8/image_thumb7.png?imgmax=800" width="506" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If you observe the XAML, it simply contains a textblock and a textbox which both binds to the same property called “Debug”.&lt;/p&gt;  &lt;p&gt;So in the codebehind, I created a property called “Debug” and in the constructor for the page (my page is called Shell), I have set the DataContext to itself. So the Binding Source should be the DataContext of the UserControl which points to itself (the instance of Shell). So Debug property should be taken from the property listed in the Shell class.&lt;/p&gt;  &lt;p&gt;While this setup works well in a WPF application, running in Silverlight terminates the application. I have noticed that when “this.DataContext = this” is placed in a Silverlight page, the application would terminate with an exception [AG_E_PARSER_BAD_PROPERTY_VALUE(Line: 8 Position: 42)].&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiBLWf0X2dI/AAAAAAAAA1A/2g2ZjciW6To/s1600-h/image26.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLWlrjVtI/AAAAAAAAA1E/6W0Jb6ZbfJ0/image_thumb14.png?imgmax=800" width="644" height="248" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Apparently, &lt;strong&gt;this.DataContext = this&lt;/strong&gt; is not being liked by the Silverlight engine. You can comment the XAML inside StackPanel and then try running the application again. You would still notice that the application fails to execute. &lt;/p&gt;  &lt;p&gt;So, the lesson learnt here is “&lt;strong&gt;&lt;u&gt;unlike in WPF, Silverlight does not like DataContext of a UserControl to be set to itself&lt;/u&gt;&lt;/strong&gt;”.&lt;/p&gt;  &lt;p&gt;So how am I going to make it work?&lt;/p&gt;  &lt;p&gt;Shown below is the fixed version. We have a&amp;#160; ShellViewModel which is instantiated within the constructor and then the data context is set to this instance.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLW-GUXCI/AAAAAAAAA1I/EzXPJes7744/s1600-h/image34%5B1%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiBLXCNYC6I/AAAAAAAAA1M/ej9rpp3Gohc/image_thumb18.png?imgmax=800" width="432" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 2: Missing Event Handler Methods can terminate your application&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Sometimes it so happens that you specify an EventHandler method in XAML but forget to implement the method in code. In that case, the compiler does not throw an error and instead a runtime exception would terminate the application. If you would like to experiment, remove the empty “private void Text….” method inside Shell class and run the application.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 3 : Data Binding makes no sense without INotifyPropertyChanged.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you look at the last code snippet, in the XAML section, both TextBlock and TextBox bind to the same “Debug” property. Now in the TextBlock LeftMouseButtonUp event handler, lets add a line which changes the value of the “Debug” property, like shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLXZZA6bI/AAAAAAAAA1Q/x6vju3-weCs/s1600-h/image38.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLXZrEaOI/AAAAAAAAA1U/_zQ4ei9nkog/image_thumb20%5B1%5D.png?imgmax=800" width="570" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now, if you run the application, and left click on the TextBlock, the event handler would be executed, the value of Debug would be updated but the UI would still show the same “Click Me!” (the default value for Debug) since it has no idea that the Debug property has been modified.&lt;/p&gt;  &lt;p&gt;To fix this and to make the UI thread aware of any changes made to the properties it binds to, the properties should either be made as Depdendency Properties or the Data Context should implement INotifyPropertyChanged and the setter of the properties should raise the PropertyChanged event.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Using INotifyPropertyChanged&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Shown below is the modified ShellViewModel which implements INofityPropertyChanged.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLXpXdLNI/AAAAAAAAA1Y/-UZAC81juXI/s1600-h/image42.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLX4SK8rI/AAAAAAAAA1c/Y25IIsQOzj0/image_thumb22.png?imgmax=800" width="593" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Using INotifyPropertyChanged is probably a better way to do things and in fact much simpler to use. In every property, the setter should raise the PropertyChanged event. Thats it!&lt;/p&gt;  &lt;p&gt;Now the application works as expected. When you click on the textblock, both the TextBlock and TextBox changes.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLYK2xiaI/AAAAAAAAA1g/-GmyyjGyDac/s1600-h/image45.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLYX1gLtI/AAAAAAAAA1k/bfUZVbiNvlM/image_thumb23.png?imgmax=800" width="135" height="74" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 4 : Be aware of Data Binding Default Mode.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;If you come from a WPF background, like me, then the same set up (XAML + code as shown until now) would behave differently in Silverlight. In WPF, if you change the text inside the textbox and tab out, you would notice the text in the text block change as well. But this does not happen in case of Silverlight. Proof ?? Try it or believe what is shown in the picture below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLYdSdRdI/AAAAAAAAA1o/x06XRk_NGDk/s1600-h/image48.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLYoIvzcI/AAAAAAAAA1s/BZ0NXqhRYuM/image_thumb24.png?imgmax=800" width="228" height="75" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice that the text block still shows the old text in spite of the text changed in the textbox (which also binds to the same property as the text block). The reason for this not to work is that in WPF the default Binding Mode is TwoWay, while in Silverlight its OneWay. For those who do not know, TwoWay means changes in the source (data) would also update the target (UI) while OneWay only updates the source when the target is changed by the user (at least that is what I understand they mean).&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;What’s the fix?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLYqfz4zI/AAAAAAAAA1w/8xMZQj87c04/s1600-h/image71.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLY3jSSBI/AAAAAAAAA10/imnAIV1rpUM/image_thumb2.png?imgmax=800" width="644" height="168" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLZGCGwbI/AAAAAAAAA14/J1HJ1M69swg/s1600-h/image8%5B1%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiBLZZaTErI/AAAAAAAAA18/UsEGcTJJ-xM/image_thumb3.png?imgmax=800" width="282" height="64" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Silverlight Dependency Properties &lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Look at this article : &lt;a title="http://blogs.sqlxml.org/bryantlikes/archive/2008/12/15/silverlight-dependency-properties.aspx" href="http://blogs.sqlxml.org/bryantlikes/archive/2008/12/15/silverlight-dependency-properties.aspx"&gt;http://blogs.sqlxml.org/bryantlikes/archive/2008/12/15/silverlight-dependency-properties.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now that I have talked about some fundamental issues one might face when starting Silverlight development, I thought I would dig more into gotchas encountered when working with Composite Silverlight applications driven by WCF services.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 5: Composite Silverlight Applications – Bootstrapper, ModuleCatalog using XAML&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Assumptions : I assume you have downloaded the Composite WPF/Silverlight (PRISM) and built the CAL. Shown below are the Silverlight libraries that I have on my machine. I also assume you have basic understanding of what a composite application is, what silverlight module is, etc.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiBLZbF7PII/AAAAAAAAA2A/E4ZDiMoXI7w/s1600-h/image13%5B1%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiBLZlWif8I/AAAAAAAAA2E/UMdronblQX8/image_thumb5.png?imgmax=800" width="244" height="91" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;In the Silverlight project, add reference to the above libraries. Then the first step is to create a &lt;strong&gt;Bootstrapper&lt;/strong&gt;. The bootstrapper performs all the required initialization and configuration for the application. Shown below is my Bootstrapper that I have used in one of my silverlight prism applications. &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLZ5CveLI/AAAAAAAAA2I/kqgaflvQHwk/s1600-h/image4%5B1%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/SiBLaPCQpDI/AAAAAAAAA2M/l_77tPl8efY/image_thumb1%5B1%5D.png?imgmax=800" width="644" height="439" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;The bootstrapper 1) creates the shell, 2) tells how your modules are cataloged and 3) additionally, it adds new RegionAdapters to existing ones.&lt;/p&gt;  &lt;p&gt;The fun part here is the ModulesCatalog.xaml. This XAML file is used to configure my modules and the&amp;#160; contents would be shown in a while. The package uri used is always annoying to me, so I use this URI as a reference and it works. You are free to use this as a reference. Anyway, lets look at the modules catalog.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLagDVdSI/AAAAAAAAA2Q/JL42iG_2Yl0/s1600-h/image8.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLa-3mBuI/AAAAAAAAA2U/3oFVqOyKQHI/image_thumb3%5B1%5D.png?imgmax=800" width="644" height="325" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Even though each XAP file has only one module, I noticed that for the Module configuration to work properly for both WhenAvailable/OnDemand, ModuleInfoGroup has to be used.&lt;/p&gt;  &lt;p&gt;Before we look into how to make each module as a separate XAP file, lets look at how the bootstrapper has been used.&amp;#160; The App.xaml.cs has to be modified in the Application_Start method to reflect the following.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLbCC6InI/AAAAAAAAA2Y/HRsLYjQJAoU/s1600-h/image12.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://lh3.ggpht.com/_Oy9HuksgrdU/SiBLbKE-1mI/AAAAAAAAA2c/BMbgvEww8Pg/image_thumb5%5B1%5D.png?imgmax=800" width="644" height="120" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 6 : Preparing a Silverlight module as a XAP File&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;When you create a new Silverlight Library, the output of the project would be a silverlight dll which cannot be used for On Demand loading for PRISM applications. So you have to make your modules to be generated as a XAP files (which are just ZIP files). Follow the steps shown below and you would be good.&lt;/p&gt;  &lt;p&gt;1. Add a new Silverlight application project to the solution. Stress on “&lt;strong&gt;Silverlight Application”&lt;/strong&gt; not a Silverlight library.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLbXnlGNI/AAAAAAAAA2g/sMHf00dnp0U/s1600-h/image18.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://lh3.ggpht.com/_Oy9HuksgrdU/SiBLbuRw8jI/AAAAAAAAA2k/HFA8GVQCtro/image_thumb9.png?imgmax=800" width="457" height="407" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Make sure you link the control but you uncheck “Add a test page that references the application”.&lt;/p&gt;  &lt;p&gt;2. Delete the App.xaml file.Build the solution. You should see the .xap file added to the ClientBin along with the shell project. Shown below is my project structure after the build. (Notice ethe maya.sample.module.xap and also missing App.xaml inside the module project).&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiBLb015wuI/AAAAAAAAA2o/2ckLPg2Gn3s/s1600-h/image22.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLb2769jI/AAAAAAAAA2s/ffbi2J7-WHQ/image_thumb11.png?imgmax=800" width="240" height="478" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;strong&gt;&lt;u&gt;Sub-Gotcha: What if you already have a silverlight library project and you wish the build to generate a XAP file instead?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;You have to right click on the silverlight library project and “Edit Project file”. This unloads the project and opens the project file inside XML editor within Visual Studio. (Or you can open it manually in editor of your choice). The first &lt;strong&gt;PropertyGroup&lt;/strong&gt; section would like shown below. Notice the SilverlightApplication is set to &lt;strong&gt;false.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLcBaVgaI/AAAAAAAAA2w/NjFkPe_Plgg/s1600-h/image30.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLcRyoXEI/AAAAAAAAA20/sNW2i3Enc7U/image_thumb15.png?imgmax=800" width="644" height="205" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Make changes such that it looks like shown below. You have to add &lt;strong&gt;XapOutputs &lt;/strong&gt;element and set it to true.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLcm1FdbI/AAAAAAAAA24/zs-RZoysC7s/s1600-h/image34.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://lh5.ggpht.com/_Oy9HuksgrdU/SiBLc3kNESI/AAAAAAAAA28/u96ksh6u2SU/image_thumb17.png?imgmax=800" width="644" height="293" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Now reload the project. Open the project folder in Windows Explorer and go to the Properties folder. Add a new file&amp;#160; called AppManifest.xml with the contents as shown below.&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;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Deployment&lt;/span&gt; &lt;span style="color: #ff0000"&gt;xmlns&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/client/2007/deployment&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #ff0000"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: #0000ff"&gt;=&amp;quot;http://schemas.microsoft.com/winfx/2006/xaml&amp;quot;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #800000"&gt;Deployment.Parts&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Deployment.Parts&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #0000ff"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #800000"&gt;Deployment&lt;/span&gt;&lt;span style="color: #0000ff"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;  &lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now come back to Visual Studio and click on the “Show All files” icon in Visual Studio Solution Explorer selecting the library project.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiBLdLMAX_I/AAAAAAAAA3A/RvE_65azCtg/s1600-h/image41.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://lh4.ggpht.com/_Oy9HuksgrdU/SiBLdKe3VxI/AAAAAAAAA3E/D7OFpXmmABs/image_thumb20.png?imgmax=800" width="223" height="123" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You should see AppManifest.xml without any icon associated. Right click on the xml file and click “Include in Project”.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now go to the properties. The Silverlight tab should look like shown below. Specify the Xap Filename as you wish. Typically, I name it same as the Assembly name.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLdUsuE5I/AAAAAAAAA3I/jvJj8XL2XxQ/s1600-h/image38%5B1%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLduVLSKI/AAAAAAAAA3M/nVrZaY5bPPM/image_thumb19.png?imgmax=800" width="644" height="325" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;My modified Silverlight Build options screen is shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLdzN3JzI/AAAAAAAAA3Q/sYKlap8JolQ/s1600-h/image49.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://lh4.ggpht.com/_Oy9HuksgrdU/SiBLd5uk-yI/AAAAAAAAA3U/DTXffD1rJsM/image_thumb26.png?imgmax=800" width="545" height="258" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Notice that I have also set the Manifest File template to the file that we added previously.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;Sub - Gotcha : This generates the XAP file. But it isn’t being copied to the ClientBin&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;If you build the library project with the changes mentioned above, you can see the XAP file&amp;#160; generated in the Debug folder but it would not automagically sit inside the ClientBin for the Web application project. To make this happen automatically, you have to modify the web application project properties. Right click on the web application project that contains your ClientBin. Go to the Silverlight Applications tab. Click on Add. Select your project and uncheck the “add a test page that references the control” since we do not want that. Shown below is that “Add Silverlight Application” screen. Finally click “Add”.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLeNPR8II/AAAAAAAAA3Y/1P1cxM213lo/s1600-h/image53.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLeVLYG7I/AAAAAAAAA3c/InL8qABPBh8/image_thumb28.png?imgmax=800" width="587" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now build your solution and you should notice the XAP file being copied into the ClientBin folder.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 6 : Configuring Modules using XAML – ModuleCatalog : Always place the modules inside ModuleInfoGroup.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Like mentioned previously, modules can be configured via an XAML file. This configuration allows one to specify if the modules be loaded as soon as they are available or when demanded. Lets assume that you have a XAP module which is to be loaded on demand and one which is to be loaded when available. Shown below is segment of my ModulesCatalog.xaml file whose complete version has been presented previously. Somehow, ModuleInfo when placed inside ModuleInfoGroup works where as just a ModuleInfo by itself always seemed not to work (may be I did something wrong).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiBLeSM7tfI/AAAAAAAAA3g/yGZRKkJuO4U/s1600-h/image%5B4%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLek3fMII/AAAAAAAAA3k/dNAlLTBU0Gw/image_thumb%5B1%5D.png?imgmax=800" width="644" height="148" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;So how to demand a module?&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt; _moduleManager.LoadModule(&amp;quot;PerformanceCounterModule&amp;quot;);&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Where _moduleManager refers to the current ModuleManager instance. The best way to get this is to add ModuleManager parameter to the constructor and use UnityContainer to resolve the object. For example, shown below is one of the ViewModels that I use which has an instance of ModuleManager passed to its constructor. The ViewModel is not instantiated directly but instead obtained via “container.Resolve&amp;lt;&amp;gt;()” call.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLe9kg_EI/AAAAAAAAA3o/upMqUZRykrQ/s1600-h/image%5B8%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SiBLfL1XCNI/AAAAAAAAA3s/GkBfiQCKwaw/image_thumb%5B3%5D.png?imgmax=800" width="644" height="190" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Unless implemented once, these concepts are rather difficult to understand. May be I will do a walkthrough for WPF based Twitter client very soon during which we can look at how it works out. For now, I assume you understand what I am talking about.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 7 :&amp;#160; WCF Service with Silverlight Applications – Deployment, Libraries, etc….&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;First of all, lets say you have a WCF service hosted inside the Web application. Lets say you created a Silverlight library which consumes this service, thereby you get to have a ServiceReferences.ClientConfig inside this helper client library but would not be present inside the shell application. Later when you deploy the service, it would be required that you modify the configuration files since the deployed service might have a different URI than the one at development. So to overcome this, shown below is one way that I often use. This simply obtains the service end point address and it assumes that the silverlight application and the service are both hosted within the same web application. All you need to look at is the way “_remoteAddress” is determined using Application.Current.Host.Source.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLftufRsI/AAAAAAAAA3w/shfNDJ0uEqY/s1600-h/image%5B12%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SiBLf-ocAvI/AAAAAAAAA30/41Lou5XYtNs/image_thumb%5B5%5D.png?imgmax=800" width="644" height="412" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Now lets look at the application set up. Shown below is the shell project and the helper library which consumes the WCF service. Like I said before the library would be referenced and the WCF service is used instead of consuming the WCF service directly. (highlighted in the picture).&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLgEiKm_I/AAAAAAAAA38/YsLPDpRkArc/s1600-h/image%5B16%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/SiBLgYqotYI/AAAAAAAAA4A/HeC3aMPVkvA/image_thumb%5B7%5D.png?imgmax=800" width="299" height="484" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;So if you try and consume the service within the shell application you would compile and build without any issues. The namespaces would be figured out nicely (or use Ctrl + . in Visual Studio to resolve the namespace). But as you execute the application, you would face the exception shown below.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/SiBLgjO9ffI/AAAAAAAAA4E/v6Fh5po2ZVM/s1600-h/image3.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://lh4.ggpht.com/_Oy9HuksgrdU/SiBLg0WckKI/AAAAAAAAA4I/uuSBvWHtwTQ/image_thumb1.png?imgmax=800" width="531" height="239" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;The message says “Cannot find ‘ServiceReferences.ClientConfig’ in the .xap application package”. And clearly we did not place one. But if we place one in here, it might be redundant and may later cause conflict issues which is not so easy to identify (since we might forget – remember DRY). &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;To resolve this, on the shell application (named maya in my case), &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;1. Right click on the project and click “Add Existing Item”. Navigate to the library which has the actual ClientConfig file. &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;2. Select the file (ServiceReferences.ClientConfig) and then instead of clicking add, click the arrow next to “add” and click “Add as Link”.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;3. &lt;strong&gt;Remember we are adding a link. One mistake that I often do is to first click “Add as Link” and then select the file followed by clicking on &amp;quot;Add” button. I assumed the drop down whenever clicked would change the behavior of the “Add” button but this isn’t the case. &lt;u&gt;You have to first select the file and then click on “Add as Link”&lt;/u&gt;.&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh6.ggpht.com/_Oy9HuksgrdU/SiBLhPZBxDI/AAAAAAAAA4M/bqWY1Br3KfE/s1600-h/image10.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://lh5.ggpht.com/_Oy9HuksgrdU/SiBLhZBboOI/AAAAAAAAA4Q/eDX-7epLMi4/image_thumb4.png?imgmax=800" width="644" height="449" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;4. You can verify that its a linked copy by opening the shell application folder and you should not see any ClientConfig file. It should only be in the service layer library we added.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;a href="http://lh5.ggpht.com/_Oy9HuksgrdU/SiBLhhUuLkI/AAAAAAAAA4U/NdLAcW9m9H0/s1600-h/image%5B20%5D.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://lh4.ggpht.com/_Oy9HuksgrdU/SiBLhx9wHUI/AAAAAAAAA4Y/9EA-hhnbE68/image_thumb%5B9%5D.png?imgmax=800" width="644" height="417" /&gt;&lt;/a&gt; &lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;&lt;strong&gt;&lt;u&gt;Gotcha 8 : Last one … Silverlight XAP File size, Performance settings.&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;1. Not sure if it matters much but you can actually extract the XAP file and re-zip it with a better utility like WinRar or 7-Zip and gain much smaller sized XAP files.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;2. In the ASPX page that hosts the Silverlight content, you can add an attribute “MaxFrameRate” and set it to a lower value like 10. I have to be honest that I do not know if this setting would improve performance for any kind of silverlight applications or just the ones with media in it. Anyway I do it for any application I use.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;I hope this post is informative enough and slightly well organized. &lt;strong&gt;I am not an expert in any of the technologies – composite silverlight apps, wcf or even Visual Studio.&lt;/strong&gt; But i thought it would be a nice thing to share my observations with the community. So please be gentle if there is a mistake in my approach or my concepts and I would be glad to rectify them.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;Thank you.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4316141622501779432?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4316141622501779432/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4316141622501779432' title='4 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4316141622501779432'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4316141622501779432'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/05/using-wcf-silverlight-2-prism-gotchas.html' title='Using WCF + Silverlight 2 + PRISM : Gotchas'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/SiBLWW0J_DI/AAAAAAAAA08/HNp8O_D8Ck8/s72-c/image_thumb7.png?imgmax=800' height='72' width='72'/><thr:total>4</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4420978664621715368</id><published>2009-05-27T13:53:00.001-07:00</published><updated>2009-05-27T13:53:34.133-07:00</updated><title type='text'>Running KirbyBase on IronPython</title><content type='html'>&lt;p&gt;As I was looking for embedded database systems, I came across this pure python database called KirbyBase. So I decided that I would make it run on IronPython. So this post describes on how to make KirbyBase run on IronPython and using ipy.exe. Note that I am not looking at integrating this database into C# application yet. [may be in the future post]&lt;/p&gt;  &lt;p&gt;So what are the steps?&lt;/p&gt;  &lt;p&gt;1. Get the latest IronPython and install it on your machine. You should be seeing ipy.exe in the installation directory.&lt;/p&gt;  &lt;p&gt;2. Get the &lt;a href="http://www.netpromi.com/kirbybase_python.html"&gt;KirbyBase download from its website&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;3. Download and install Python 2.6 whose libraries are required to run the database tests.&lt;/p&gt;  &lt;p&gt;4. Once Kirbybase and Python 2.6 are installed, look for kbtest.py inside kirbybase installation directory.&lt;/p&gt;  &lt;p&gt;5. Copy the kbtest.py into the directory which has ipy.exe (the IronPython installation directory).&lt;/p&gt;  &lt;p&gt;6. Modify the kbtest.py to include the Python and KirbyBase directories into the path. The final result should look something like shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh3.ggpht.com/_Oy9HuksgrdU/Sh2oS-fqxbI/AAAAAAAAA0o/jSlhbVH2Z44/s1600-h/image%5B3%5D.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://lh3.ggpht.com/_Oy9HuksgrdU/Sh2oS8i6gtI/AAAAAAAAA0s/2AF6rEflp9A/image_thumb%5B1%5D.png?imgmax=800" width="420" height="313" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;Notice that I have moved “import sys” statement ahead of “import os”. The lines 2 and 3 adds the directories for Python2.6 and KirbyBase to the path.&lt;/p&gt;  &lt;p&gt;Then from command prompt type in the following&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;ipy kbtest.py&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;The result should look like shown below.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/Sh2oTCIum4I/AAAAAAAAA0w/q-vPiXWTITo/s1600-h/image%5B9%5D.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://lh6.ggpht.com/_Oy9HuksgrdU/Sh2oTT1jfDI/AAAAAAAAA00/f0_KgrTOwqw/image_thumb%5B5%5D.png?imgmax=800" width="636" height="782" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;May be next time, I would like to see what it takes to integrate this database into C# application. Until then, have a nice time. Let me know if you have better approaches than what I did here. Thank you.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4420978664621715368?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4420978664621715368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4420978664621715368' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4420978664621715368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4420978664621715368'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/05/running-kirbybase-on-ironpython.html' title='Running KirbyBase on IronPython'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh3.ggpht.com/_Oy9HuksgrdU/Sh2oS8i6gtI/AAAAAAAAA0s/2AF6rEflp9A/s72-c/image_thumb%5B1%5D.png?imgmax=800' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-4373443099428142099</id><published>2009-05-26T14:08:00.001-07:00</published><updated>2009-05-26T14:08:38.878-07:00</updated><title type='text'>Debugging W3WP with “Attach to Process”</title><content type='html'>&lt;p&gt;When trying to load SOS.dll while the debugger is attached to the w3wp process, if you encounter the following message.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;SOS not available while Managed only debugging.&amp;#160; To load SOS, enable unmanaged debugging in your project properties.&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Then, stop the debugging session and in the “attach to process” dialog, select your process and click on the “select” button. Then you can pick what kind of debugging sessions would you like to permit.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/ShxaVN2TwYI/AAAAAAAAA0Y/JjpY4Zzi-Qs/s1600-h/image%5B6%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/ShxaVXajpFI/AAAAAAAAA0c/g_4SXy__Mns/image_thumb%5B2%5D.png?imgmax=800" width="482" height="256" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;By default, the code to debug is automatically determined in which case only Managed and T-SQL debugging is enabled.&lt;/p&gt;  &lt;p&gt;Another useful feature would be using “New Breakpoint” functionality. This would be useful when you are using&amp;#160; Attach to Process and do not have the source code opened as a project. In this case, you can go to Debug-&amp;gt;New Breakpoint-&amp;gt; Break at function.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://lh4.ggpht.com/_Oy9HuksgrdU/ShxaVZai4jI/AAAAAAAAA0g/8Exn9_NTIUs/s1600-h/image%5B10%5D.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://lh5.ggpht.com/_Oy9HuksgrdU/ShxaVjDKmDI/AAAAAAAAA0k/6iV6ULFk3r8/image_thumb%5B4%5D.png?imgmax=800" width="598" height="271" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;&lt;/p&gt;  &lt;p&gt;Once you are in this window, give the function name where you want to break and then click OK. Ignore any warning messages that it gives and then it would hit the breakpoint if the function you named would be executed. I will be posting more as I learn more about using SOS.dll with W3WP.&lt;/p&gt;  &lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/19967453-4373443099428142099?l=krishnabhargav.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://krishnabhargav.blogspot.com/feeds/4373443099428142099/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=19967453&amp;postID=4373443099428142099' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4373443099428142099'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/19967453/posts/default/4373443099428142099'/><link rel='alternate' type='text/html' href='http://krishnabhargav.blogspot.com/2009/05/debugging-w3wp-with-attach-to-process.html' title='Debugging W3WP with “Attach to Process”'/><author><name>Krishna Bhargava Vangapandu</name><uri>http://www.blogger.com/profile/16813193547125152985</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='29' height='32' src='http://4.bp.blogspot.com/-MB-b0g_Wo8g/Tt7niL0zoCI/AAAAAAAABcA/JY6LJnerJIA/s220/suit.PNG'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh5.ggpht.com/_Oy9HuksgrdU/ShxaVXajpFI/AAAAAAAAA0c/g_4SXy__Mns/s72-c/image_thumb%5B2%5D.png?imgmax=800' height='72' width='72'/><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-19967453.post-5336160840756280119</id><published>2009-05-20T12:34:00.001-07:00</published><updated>2009-05-20T12:34:49.766-07:00</updated><title type='text'>Using Blueprint CSS in ASP.NET MVC</title><content type='html'>&lt;p&gt;I know my previous post on the blog is incomplete but I promise to get back to that complete as soon as possible. In the meantime, here is a quick info on how to include Blueprint CSS files within ASP.NET MVC applications. I add this to my Site.Master page.&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: #006080"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;link&lt;/span&gt; href=&amp;quot;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;%=Url&lt;span style="color: #cc6633"&gt;.Content&lt;/span&gt;(&amp;quot;~/Content/Site&lt;span style="color: #cc6633"&gt;.css&lt;/span&gt;&amp;quot;) %&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&amp;quot; rel=&amp;quot;stylesheet&amp;quot; type=&amp;quot;text/css&amp;quot; /&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #006080"&gt;&amp;lt;&lt;/span&gt;!-- Framework CSS --&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #006080"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;link&lt;/span&gt; rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;%= Url&lt;span style="color: #cc6633"&gt;.Content&lt;/span&gt;(&amp;quot;~/Content/blueprint/screen&lt;span style="color: #cc6633"&gt;.css&lt;/span&gt;&amp;quot;)%&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&amp;quot;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;         type=&amp;quot;text/css&amp;quot; media=&amp;quot;screen, projection&amp;quot;&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #0000ff"&gt;link&lt;/span&gt; rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;&lt;span style="color: #006080"&gt;&amp;lt;&lt;/span&gt;%= Url&lt;span style="color: #cc6633"&gt;.Content&lt;/span&gt;(&amp;quot;~/Content/blueprint/print&lt;span style="color: #cc6633"&gt;.css&lt;/span&gt;&amp;quot;)%&lt;span style="color: #006080"&gt;&amp;gt;&lt;/span&gt;&amp;quot;&lt;/pre&gt;&lt;br /&gt;&lt;br /&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: #606
