<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Chaitanya Venneti</title>
	<atom:link href="http://www.chaitanyavenneti.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.chaitanyavenneti.com</link>
	<description>On Silverlight, Windows Phone 7 and other interesting stuff</description>
	<lastBuildDate>Tue, 07 Aug 2012 16:07:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4.1</generator>
		<item>
		<title>Metrofy &#8211; Responsive Metro Inspired HTML Template on ThemeForest</title>
		<link>http://www.chaitanyavenneti.com/themes-2/metrofy-responsive-metro-inspired-html-template-on-themeforest/</link>
		<comments>http://www.chaitanyavenneti.com/themes-2/metrofy-responsive-metro-inspired-html-template-on-themeforest/#comments</comments>
		<pubDate>Tue, 07 Aug 2012 16:05:11 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Themes]]></category>
		<category><![CDATA[Templates]]></category>
		<category><![CDATA[ThemeForest]]></category>
		<category><![CDATA[themes]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1356</guid>
		<description><![CDATA[Metrofy is my first item on ThemeForest, a responsive Metro inspired HTML Template. Metrofy is specially designed based on the Metro Design Language. This template was designed for creating portfolios, agency &#38; consulting firm websites and corporate websites. Metrofy comes with 3 different homepage sliders. Slider with Tiles Elastic Slider Flex Slider The Tiles Layout, ]]></description>
			<content:encoded><![CDATA[<p><a href="http://themeforest.net/item/metrofy-responsive-metro-inspired-template/2650203">Metrofy</a> is my first item on ThemeForest, a responsive Metro inspired HTML Template.</p>
<div id="attachment_1357" class="wp-caption aligncenter" style="width: 619px"><a href="http://themeforest.net/item/metrofy-responsive-metro-inspired-template/2650203?ref=TheMetroGuy"><img class="size-full wp-image-1357" title="Metrofy - Responsive Metro Inspired HTML Template on ThemeForest" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/08/skin.jpg" alt="Metrofy - Responsive Metro Inspired HTML Template on ThemeForest" width="609" height="458" /></a>
<p class="wp-caption-text">Metrofy &#8211; Responsive Metro Inspired HTML Template on ThemeForest</p>
</div>
<p>Metrofy is specially designed based on the Metro Design Language.</p>
<p>This template was designed for creating portfolios, agency &amp; consulting firm websites and corporate websites.</p>
<p>Metrofy comes with 3 different homepage sliders.</p>
<ol>
<li>Slider with Tiles</li>
<li>Elastic Slider</li>
<li>Flex Slider</li>
</ol>
<div><span id="more-1356"></span></div>
<p>The Tiles Layout, the elastic and Flex sliders will help you present your content beautifully, be it your line of products or services or portfolio items.</p>
<p>This template contains 10 different pages with the following features.</p>
<ul>
<li>Home page with 3 different sliders</li>
<li>Scrollable home page</li>
<li>Blog page with 2 layouts</li>
<li>Blog post with Video, Featured image or Slider</li>
<li>Filterable Portfolio</li>
<li>Portfolio Item with featured slider</li>
<li>CSS Pricing Table</li>
<li>Fully Responsive</li>
<li>960 Grid based</li>
<li>HTML5 &amp; CSS3</li>
</ul>
<div><a href="http://themeforest.net/item/metrofy-responsive-metro-inspired-template/2650203?ref=TheMetroGuy">Click here</a> to buy this template from ThemeForest.</div>
<p>A WordPress version is under development and will be available soon.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/themes-2/metrofy-responsive-metro-inspired-html-template-on-themeforest/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Buy It Next: One stop shop for all your shopping lists</title>
		<link>http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/</link>
		<comments>http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/#comments</comments>
		<pubDate>Fri, 16 Mar 2012 05:29:29 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[WP7]]></category>
		<category><![CDATA[app]]></category>
		<category><![CDATA[freebie]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1340</guid>
		<description><![CDATA[Buy It Next is another Windows Phone app from me, for managing your Shopping Lists. Features Create and manage multiple shopping lists Color coded lists for easy categorization Intuitive Metro interface &#160; Screenshots Download Buy It Next is now live in the Marketplace. Click here to download it]]></description>
			<content:encoded><![CDATA[<p><a title="Download from Marketplace" href="http://windowsphone.com/s?appid=171d41b3-af5e-4334-a118-59e039da6fb5" target="_blank">Buy It Next</a> is another Windows Phone app from me, for managing your Shopping Lists.</p>
<p><strong>Features</strong></p>
<ul>
<li>Create and manage multiple shopping lists</li>
<li>Color coded lists for easy categorization</li>
<li>Intuitive Metro interface</li>
</ul>
<div>&nbsp;</div>
<div><span id="more-1340"></span></div>
<p><strong>Screenshots</strong></p>
<p><a href='http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/attachment/splashscreenimage/' title='SplashScreenImage'><img width="480" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/03/SplashScreenImage-480x220.png" class="attachment-thumbnail" alt="SplashScreenImage" title="SplashScreenImage" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/attachment/tiles/' title='Tiles'><img width="480" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/03/Tiles-480x220.png" class="attachment-thumbnail" alt="Tiles" title="Tiles" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/attachment/black-text-tile/' title='black text tile'><img width="480" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/03/black-text-tile-480x220.png" class="attachment-thumbnail" alt="black text tile" title="black text tile" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/attachment/edit-list-name/' title='Edit List Name'><img width="480" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/03/Edit-List-Name-480x220.png" class="attachment-thumbnail" alt="Edit List Name" title="Edit List Name" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/attachment/list/' title='List'><img width="480" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/03/List-480x220.png" class="attachment-thumbnail" alt="List" title="List" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/attachment/list-color/' title='List Color'><img width="480" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2012/03/List-Color-480x220.png" class="attachment-thumbnail" alt="List Color" title="List Color" /></a></p>
<p><strong>Download</strong></p>
<p>Buy It Next is now live in the Marketplace. <a href="http://windowsphone.com/s?appid=171d41b3-af5e-4334-a118-59e039da6fb5" target="_blank">Click here</a> to download it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/wp7/buy-it-next-one-stop-shop-for-all-your-shopping-lists/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do it, Push it : My first Windows Phone app in the Marketplace</title>
		<link>http://www.chaitanyavenneti.com/topics/wp7/do-it-push-it-my-first-windows-phone-app-in-the-marketplace/</link>
		<comments>http://www.chaitanyavenneti.com/topics/wp7/do-it-push-it-my-first-windows-phone-app-in-the-marketplace/#comments</comments>
		<pubDate>Wed, 07 Mar 2012 15:43:06 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[WP7]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1329</guid>
		<description><![CDATA[My first Windows Phone application &#8216;Do it, Push it&#8217; crossed 600+ downloads. It&#8217;s a simple to-do list for Procrastinators. Yes, Planning is a tedious task. So why not just list down things and in the end push the pending ones to tomorrow or future. Use the link below to download the app from Windows Phone Marketplace. ]]></description>
			<content:encoded><![CDATA[<p>My first Windows Phone application &#8216;Do it, Push it&#8217; crossed 600+ downloads.</p>
<p>It&#8217;s a simple to-do list for Procrastinators.</p>
<p>Yes, Planning is a tedious task. So why not just list down things and in the end push the pending ones to tomorrow or future.</p>
<p><span id="more-1329"></span></p>
<p>Use the link below to download the app from Windows Phone Marketplace.</p>
<p><a href="http://windowsphone.com/s?appid=74139710-de4d-46ca-b7c1-17c7ffc8af6d"><img class="alignnone" title="Download from Marketplace" src="http://apps.themetroguy.com/DoItPushIt/public/images/wp7_English_300x50_red.png" alt="Download from Marketplace" width="300" height="50" /></a></p>
<p><strong>Do it, Push it Features</strong></p>
<ul>
<li>A simple to do list, with optional task description.</li>
<li>If not today, push tasks to tomorrow.</li>
<li>Pending tasks will be automatically moved to tomorrow.</li>
<li>Prioritize and unprioritize tasks.</li>
<li>Move tasks between today and tomorrow.</li>
<li>Live tile support for reminding about important tasks.</li>
</ul>
<p>For feedback and learning about future updates of the application, check <a href="http://apps.themetroguy.com/">http://apps.themetroguy.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/wp7/do-it-push-it-my-first-windows-phone-app-in-the-marketplace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Windows Phone UX: When &amp; How to use Panorama Control</title>
		<link>http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/</link>
		<comments>http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 13:45:10 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Topics]]></category>
		<category><![CDATA[WP7]]></category>
		<category><![CDATA[metro]]></category>
		<category><![CDATA[UX]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1278</guid>
		<description><![CDATA[Panorama or Panoramic Control often referred as a &#8216;hub&#8217; is where you can represent the UI of the application on a lengthy horizontal canvas that extends beyond the device boundaries. The scrollable UI of the Panorama allows for a unique visual experience associated with the overall feel of Windows Phone 7. And is often the entry ]]></description>
			<content:encoded><![CDATA[<p>Panorama or Panoramic Control often referred as a &#8216;hub&#8217; is where you can represent the UI of the application on a lengthy horizontal canvas that extends beyond the device boundaries.</p>
<p>The scrollable UI of the Panorama allows for a unique visual experience associated with the overall feel of Windows Phone 7. And is often the entry point for many applications.</p>
<p>Which means you need to be more careful with the quality of your Panorama and the feel it leaves.</p>
<p>The best examples are always on the device. The People hub on the Start screen is implemented using a Panorama and so is the Music + Videos hub.</p>
<p><span id="more-1278"></span></p>
<h3>DOs and DON&#8217;Ts of using a Panorama</h3>
<ul>
<li>It is better to use the Panorama as an entry point providing access to deeper content, instead of making the Panorama itself the entire app.</li>
<li>Limit the maximum number of panes to 6. The magic number is 4, as recommended by Microsoft to ensure smooth application performance.</li>
<li>Maintain a good mix of content formats across the panes. For example, if all the panes need show lists, it is better to go for a Pivot instead of Panorama.</li>
<li>Never fill the Panorama with floating buttons.</li>
<li>Take care of the space between items. Make better use of typography.</li>
<li>Use images sparsely and make sure they are relevant and linked to the content.</li>
<li>Use backgrounds with caution. Make sure the text is readable. It is better to use a light textured pattern or a photograph if it&#8217;s relevant to the content.</li>
<li>Don&#8217;t fill the application with your branding (logos and other images). You may change the accent colors in the app to your brand colors and show your logo on the top left of the first pane.</li>
</ul>
<p>Below are screenshots of some apps showcasing the best practices,</p>
<div>
<p><a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/2158-image_7adb684c/' title='Office'><img width="580" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/2158.image_7ADB684C-580x220.jpg" class="attachment-thumbnail" alt="Office" title="Office" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/7485-blue_yonder_pano_0f5c41ae/' title='7485.Blue_Yonder_pano_0F5C41AE'><img width="580" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/7485.Blue_Yonder_pano_0F5C41AE-580x220.jpg" class="attachment-thumbnail" alt="7485.Blue_Yonder_pano_0F5C41AE" title="7485.Blue_Yonder_pano_0F5C41AE" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/arpanoramarender/' title='ARpanoramarender'><img width="580" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/ARpanoramarender-580x220.jpg" class="attachment-thumbnail" alt="ARpanoramarender" title="ARpanoramarender" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/design-918/' title='design-918'><img width="620" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/design-918-620x220.png" class="attachment-thumbnail" alt="design-918" title="design-918" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/evernote-windows-phone-7/' title='Evernote-Windows-Phone-7-'><img width="620" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/Evernote-Windows-Phone-7--620x220.jpg" class="attachment-thumbnail" alt="Evernote-Windows-Phone-7-" title="Evernote-Windows-Phone-7-" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/imdb_940_17/' title='IMDb_940_17'><img width="620" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/IMDb_940_17-620x220.jpg" class="attachment-thumbnail" alt="IMDb_940_17" title="IMDb_940_17" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/yelp/' title='yelp'><img width="580" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/yelp-580x220.png" class="attachment-thumbnail" alt="yelp" title="yelp" /></a><br />
<a href='http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/attachment/ux_panorama/' title='UX_Panorama'><img width="620" height="220" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/10/UX_Panorama.png" class="attachment-thumbnail" alt="UX_Panorama" title="UX_Panorama" /></a></p>
</div>
<p>Thanks for reading. Please provide your thoughts and ideas on creating better designs using Panorama. In next post, we&#8217;ll cover best practices using Pivot and Tiles.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/windows-phone-ux-when-how-to-use-panorama-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WP7 Databound Application &#8211; Pizza App User Interface Design</title>
		<link>http://www.chaitanyavenneti.com/topics/wp7-pizza-app-ui/</link>
		<comments>http://www.chaitanyavenneti.com/topics/wp7-pizza-app-ui/#comments</comments>
		<pubDate>Thu, 21 Jul 2011 16:17:49 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Topics]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1132</guid>
		<description><![CDATA[Last week, in the introduction to a Windows Phone 7 Databound application, we saw how a databound application works and how to show a collection on the UI. In this second part, we&#8217;ll see how to convert it in to a real world app. Things we cover Adding new pages Wiring up events Creating a ]]></description>
			<content:encoded><![CDATA[<p>Last week, in the <a title="Introduction to WP7 Databound application" href="http://www.chaitanyavenneti.com/topics/wp7-databound-app-intro/" target="_blank">introduction to a Windows Phone 7 Databound application</a>, we saw how a databound application works and how to show a collection on the UI.</p>
<p>In this second part, we&#8217;ll see how to convert it in to a real world app.</p>
<h2>Things we cover</h2>
<ul>
<li>Adding new pages</li>
<li>Wiring up events</li>
<li>Creating a custom panel, the secret behind the toppings selection screen</li>
</ul>
<p></p>
<div>Before going further, let&#8217;s see what we are going to create. Below are the screen-shots of the completed application.</div>
<p></p>
<div><span id="more-1132"></span></div>
<div><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/pizza_screens_3.png" rel="wp-prettyPhoto[g1132]"><img class="aligncenter size-full wp-image-1213" title="Pizza App Screen-shot" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/pizza_screens_3.png" alt="Pizza App Screen-shot" width="625" height="529" /></a></div>
<div><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/pizza_screens_1_2.png" rel="wp-prettyPhoto[g1132]"><img class="aligncenter size-full wp-image-1214" title="Pizza App Screen-shot" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/pizza_screens_1_2.png" alt="Pizza App Screen-shot" width="628" height="531" /></a></div>
<div></div>
<div>If you observe closely, the toppings selections screen (shown left side in the above image) shows the Pizza topped only with the selected toppings. We&#8217;ll cover it later in the tutorial, first let&#8217;s start with the ViewModel.</div>
<div></div>
<h3>Updating the ViewModel</h3>
<p>We create the pizza items with the following structure,</p>
<ol>
<li><strong>ItemName</strong> <em>String</em> The name of a crust item or a topping</li>
<li><strong>ItemImage</strong> <em>String</em> Image path of a crust item or a topping</li>
<li><strong>ItemDescription</strong> <em>String</em> Description of the item</li>
<li><strong>IsSelected</strong> <em>Boolean</em> Indicating if the item is selected</li>
</ol>
<p>Open the <em>ItemViewModel.cs</em> class file and replace the existing properties with the following properties,</p>
<pre class="brush: csharp; title: ; notranslate">    
private string _ItemName;
        public string ItemName 
        {
            get 
            {
                return _ItemName;
            }
            set 
            {
                _ItemName = value;
                NotifyPropertyChanged(&quot;ItemName&quot;);
            }
        }

        private string _ItemImage;
        public string ItemImage
        {
            get
            {
                return _ItemImage;
            }
            set
            {
                _ItemImage = value;
                NotifyPropertyChanged(&quot;ItemImage&quot;);
            }
        }

        private string _ItemDescription;        
        public string ItemDescription
        {
            get
            {
                return _ItemDescription;
            }
            set
            {
                _ItemDescription = value;
                NotifyPropertyChanged(&quot;ItemDescription&quot;);
            }
        }

        private bool _IsSelected;

        public bool IsSelected
        {
            get { return _IsSelected; }
            set
            {
                _IsSelected = value;
                NotifyPropertyChanged(&quot;IsSelected&quot;);
            }
        }

        public event PropertyChangedEventHandler PropertyChanged;
        private void NotifyPropertyChanged(String propertyName) 
        {
            if (null != PropertyChanged) 
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }
</pre>
<h3>Add sample data</h3>
<p>Open <em>MainViewModel.cs.</em></p>
<p>We will create two collection objects of type <em>ItemViewModel </em>for Crust Items and Toppings,</p>
<pre class="brush: csharp; title: ; notranslate">    
public ObservableCollection CrustItems { get; private set; }     
public ObservableCollection Toppings { get; private set; }     
</pre>
<p>Now, instantiate the collections in the constructor,</p>
<pre class="brush: csharp; title: ; notranslate">    
this.CrustItems = new ObservableCollection();     
this.Toppings = new ObservableCollection();     
</pre>
<p>Find the method <em>LoadData </em>and replace the method with the following code,</p>
<pre class="brush: csharp; title: ; notranslate">
public void LoadData()
        {
            #region // Sample data; Crust Items
            
            //Sample data: Crusts
            this.CrustItems.Add(new ItemViewModel() { ItemName = &quot;Handmade&quot;, ItemImage = &quot;../Images/hand.png&quot;,
                ItemDescription = &quot;Delicious and soft handmade crust&quot;});
            this.CrustItems.Add(new ItemViewModel() { ItemName = &quot;Natural&quot;, ItemImage = &quot;../Images/natural.png&quot;, 
                ItemDescription = &quot;Crust with selected natural dough&quot; });
            this.CrustItems.Add(new ItemViewModel() { ItemName = &quot;Pan Crust&quot;, ItemImage = &quot;../Images/pan.png&quot;, 
                ItemDescription = &quot;Traditional Italian Crust&quot; });
            this.CrustItems.Add(new ItemViewModel() { ItemName = &quot;Stuffed Crust&quot;, ItemImage = &quot;../Images/stuffed.png&quot;, 
                ItemDescription = &quot;Seasoned with garlic, stuffed with cheese&quot; });
            this.CrustItems.Add(new ItemViewModel() { ItemName = &quot;Thin N Crispy Crust&quot;, ItemImage = &quot;../Images/thincrispy.png&quot;, 
                ItemDescription = &quot;Bread dough with cracked crust&quot; });
            
            // Sample data: Toppings
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Ham&quot;, ItemImage = &quot;../Images/toppings/ham.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Grilled Chicken&quot;, ItemImage = &quot;../Images/toppings/grilled_chicken.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Italian Sausage&quot;, ItemImage = &quot;../Images/toppings/italian_sausage_crumbled.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Black Olives&quot;, ItemImage = &quot;../Images/toppings/olives_black.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Green Olives&quot;, ItemImage = &quot;../Images/toppings/olives_green.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Mushrooms&quot;, ItemImage = &quot;../Images/toppings/mushrooms.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Pepperoni&quot;, ItemImage = &quot;../Images/toppings/pepperoni.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;White Onions&quot;, ItemImage = &quot;../Images/toppings/onions_white.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Red Onions&quot;, ItemImage = &quot;../Images/toppings/onions_red.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Diced Tomatoes&quot;, ItemImage = &quot;../Images/toppings/tomatoes_diced.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Roma Tomatoes&quot;, ItemImage = &quot;../Images/toppings/tomatoes_roma.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Pineapple&quot;, ItemImage = &quot;../Images/toppings/pineapple.png&quot; });
            this.Toppings.Add(new ItemViewModel() { ItemName = &quot;Jalapenos&quot;, ItemImage = &quot;../Images/toppings/jalapenos.png&quot; });
             
            #endregion
         
            this.IsDataLoaded = true;            
        }
</pre>
<p>Now we have our ViewModel ready, let&#8217;s create the UI.</p>
<h2>Creating the Application Screens</h2>
<h3>Start Screen (MainPage.xaml)</h3>
<p>Open MainPage.xaml.</p>
<p>Remove the ListBox named <em>MainListBox </em>and add a button,</p>
<pre class="brush: xml; title: ; notranslate">
 &lt;Button x:Name=&quot;cmdPizzaStart&quot; Content=&quot;Make your Pizza&quot; 
                    Click=&quot;cmdPizzaStart_Click&quot; Height=&quot;100&quot; Width=&quot;300&quot;/&gt;
</pre>
<p>In the event handler, add the below code to navigate to Crust Selection screen,</p>
<pre class="brush: csharp; title: ; notranslate">
NavigationService.Navigate(new Uri(&quot;/CrustSelection.xaml&quot;, UriKind.Relative));
</pre>
<h3>Crust Selection Screen (CrustSelection.xaml)</h3>
<p>Right click on the project in &#8216;Solution Explorer&#8217; and add a new &#8216;Windows Phone Portrait Page&#8217; to the project. Name it &#8216;CrustSelection.xaml&#8217;.</p>
<p>Go to xaml view and replace the ContentPanel with the following code,</p>
<pre class="brush: xml; title: ; notranslate">
        &lt;Grid x:Name=&quot;ContentPanel&quot; Grid.Row=&quot;1&quot; Margin=&quot;12,0,12,0&quot;
              Background=&quot;DarkRed&quot;&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition/&gt;
                &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
            &lt;/Grid.RowDefinitions&gt;

            &lt;controls:Panorama ItemsSource=&quot;{Binding CrustItems}&quot; x:Name=&quot;crustList&quot;&gt;
                &lt;controls:Panorama.ItemTemplate&gt;
                    &lt;DataTemplate&gt;
                            &lt;Image Source=&quot;{Binding ItemImage}&quot; HorizontalAlignment=&quot;Center&quot;/&gt;
                    &lt;/DataTemplate&gt;
                &lt;/controls:Panorama.ItemTemplate&gt;
                &lt;controls:Panorama.HeaderTemplate&gt;
                    &lt;DataTemplate&gt;
                            &lt;TextBlock Text=&quot;{Binding ItemName}&quot; TextWrapping=&quot;Wrap&quot; 
                                       HorizontalAlignment=&quot;Center&quot;
                                       Style=&quot;{StaticResource PhoneTextExtraLargeStyle}&quot;/&gt;
                    &lt;/DataTemplate&gt;
                &lt;/controls:Panorama.HeaderTemplate&gt;
            &lt;/controls:Panorama&gt;
            &lt;Button x:Name=&quot;cmdSelectCrust&quot; Content=&quot;Select Toppings&quot; Grid.Row=&quot;1&quot;
                    HorizontalAlignment=&quot;Center&quot; Click=&quot;cmdSelectCrust_Click&quot;
                    IsEnabled=&quot;{Binding SelectedIndex, ElementName=MainListBox, Converter={StaticResource IndexToEnabledConverter}}&quot;/&gt;
        &lt;/Grid&gt;
</pre>
<p>Let&#8217;s see what we have in the above code snippet,</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/panorama_1.png" rel="wp-prettyPhoto[g1132]"><img class="aligncenter size-full wp-image-1219" title="Panorama" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/panorama_1.png" alt="Panorama" width="600" height="228" /></a></p>
<p>It creates a Panorama control bound to the CrustItems collection. The ItemTemplate contains an Image with Source property bound to ItemImage property. The HeaderTemplate contains a TextBlock with the Text property bound to ItemName.</p>
<p>Below is the panorama in action,</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/crustselection.png" rel="wp-prettyPhoto[g1132]"><img class="aligncenter size-full wp-image-1220" title="CrustSelection_Panorama" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/crustselection.png" alt="CrustSelection_Panorama" width="310" height="529" /></a></p>
<p>Add the below line in the click event handler of the button cmdSelectCrust, to navigate to Toppings Selection screen when clicked.</p>
<pre class="brush: csharp; title: ; notranslate">
NavigationService.Navigate(new Uri(&quot;/ToppingsSelections.xaml?selectedItem=&quot; + crustList.SelectedIndex, UriKind.Relative));
</pre>
<h3>Toppings Selection Screen (ToppingsSelection.xaml)</h3>
<p>Add a new ‘Windows Phone Portrait Page’ to the project and name it ‘ToppingsSelection.xaml’.</p>
<p>Update the ContentPanel Grid as shown,</p>
<pre class="brush: csharp; title: ; notranslate">
&lt;Grid x:Name=&quot;ContentPanel&quot; Grid.Row=&quot;1&quot; Margin=&quot;12,0,12,0&quot; Background=&quot;DarkRed&quot;&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition/&gt;
                &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
            &lt;/Grid.RowDefinitions&gt;
			&lt;Grid.ColumnDefinitions&gt;
				&lt;ColumnDefinition/&gt;
				&lt;ColumnDefinition/&gt;
			&lt;/Grid.ColumnDefinitions&gt;	
            &lt;ListBox x:Name=&quot;MainListBox&quot; Margin=&quot;0,0,-12,0&quot; ItemsSource=&quot;{Binding Toppings}&quot; 
                     ScrollViewer.HorizontalScrollBarVisibility=&quot;Visible&quot;&gt;                
                &lt;ListBox.ItemTemplate&gt;
                    &lt;DataTemplate&gt;
                        &lt;CheckBox Content=&quot;{Binding ItemName}&quot; IsChecked=&quot;{Binding IsSelected, Mode=TwoWay}&quot;
                                  Click=&quot;CheckBox_Click&quot;/&gt;
                    &lt;/DataTemplate&gt;
                &lt;/ListBox.ItemTemplate&gt;                
            &lt;/ListBox&gt;
            
            &lt;StackPanel x:Name=&quot;SelectedCrust&quot; Grid.Column=&quot;1&quot;&gt;
                &lt;Grid&gt;
                    &lt;Image Source=&quot;{Binding ItemImage}&quot; Width=&quot;416&quot; Height=&quot;356&quot;/&gt;
                    &lt;ItemsControl x:Name=&quot;lstSelectedToppings&quot; BorderThickness=&quot;1&quot;&gt;
                        &lt;ItemsControl.ItemsPanel&gt;
                            &lt;ItemsPanelTemplate&gt;
                                &lt;local:CustomPanel Background=&quot;Transparent&quot;/&gt;
                            &lt;/ItemsPanelTemplate&gt;
                        &lt;/ItemsControl.ItemsPanel&gt;
                        &lt;ItemsControl.ItemTemplate&gt;
                            &lt;DataTemplate&gt;
                                &lt;Image Source=&quot;{Binding ItemImage}&quot; Width=&quot;416&quot; Height=&quot;356&quot;/&gt;
                            &lt;/DataTemplate&gt;
                        &lt;/ItemsControl.ItemTemplate&gt;
                    &lt;/ItemsControl&gt;
                &lt;/Grid&gt;
                &lt;StackPanel&gt;
                    &lt;TextBlock Text=&quot;Crust Choice:&quot; HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot;/&gt;
                    &lt;TextBlock Text=&quot;{Binding ItemName}&quot; HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot;/&gt;
                &lt;/StackPanel&gt;
            &lt;/StackPanel&gt;
            &lt;Button x:Name=&quot;cmdReviewOrder&quot; Content=&quot;Check out&quot; Grid.Row=&quot;1&quot; Grid.ColumnSpan=&quot;2&quot;
                    HorizontalAlignment=&quot;Right&quot; Click=&quot;cmdReviewOrder_Click&quot;
                    IsEnabled=&quot;{Binding SelectedIndex, ElementName=MainListBox, Converter={StaticResource IndexToEnabledConverter}}&quot;/&gt;
        &lt;/Grid&gt;
</pre>
<p>The image shown below explains the layout of ToppingsSelection.</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/toppings_layout.png" rel="wp-prettyPhoto[g1132]"><img style="display: inline;" title="toppings_layout" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/toppings_layout_thumb.png" alt="toppings_layout" width="260" height="446" /></a> <a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Toppings1.png" rel="wp-prettyPhoto[g1132]"><img style="display: inline;" title="Toppings" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Toppings_thumb.png" alt="Toppings" width="267" height="446" /></a></p>
<p>In code-behind, override the OnNavigatedTo method and update the data context.</p>
<p>OnNavigatedTo is executed when ever user navigates to the page. We will read the selected crust value and selected toppings if any and update the UI.</p>
<pre class="brush: csharp; title: ; notranslate">
protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string selectedIndex = &quot;&quot;;
            if (NavigationContext.QueryString.TryGetValue(&quot;selectedItem&quot;, out selectedIndex))
            {
                index = int.Parse(selectedIndex);
                SelectedCrust.DataContext = App.ViewModel.CrustItems[index];
                UpdateExistingToppings();
            }
        }
private void UpdateExistingToppings()
        {
            lstSelectedToppings.ItemsSource = null;

            var selectedToppings = from p in App.ViewModel.Toppings
                                   where p.IsSelected
                                   select p;

            if (selectedToppings != null &amp;&amp; selectedToppings.Count() &gt; 0)
            {
                lstSelectedToppings.ItemsSource = selectedToppings;
            }
        }
</pre>
<p>When ever user changes the toppings selections, call the method UpdateExistingToppings, which updates the selected topping images on the right side.</p>
<p>Navigate to order review page when clicked on ‘Check Out’.</p>
<pre class="brush: csharp; title: ; notranslate">
        private void cmdReviewOrder_Click(object sender, RoutedEventArgs e)
        {
            NavigationService.Navigate(new Uri(&quot;/OrderReview.xaml?selectedItem=&quot; + index, UriKind.Relative));
        }

        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            UpdateExistingToppings();
        }
</pre>
<h3>Custom Panel</h3>
<p>The selected toppings ItemsControl, uses a ‘CustomPanel’ as ItemsPanelTemplate, which shows the toppings layered over each other as we see on a real pizza.</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/code_custompanel1.png" rel="wp-prettyPhoto[g1132]"><img style="display: inline;" title="code_custompanel" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/code_custompanel_thumb.png" alt="code_custompanel" width="552" height="238" /></a></p>
<p>For detailed information on Custom Panel check <a href="http://www.chaitanyavenneti.com/topics/custom-panel-in-silverlight/">Silverlight Custom Panel</a> blog post.</p>
<h3>Order Review Page (OrderReview.xaml)</h3>
<p>Add another ‘Windows Phone Portrait Page’ and name it ‘OrderReview.xaml’</p>
<p>Update the ContentPanel with the following code, which shows a simple form for user address input and user selections. Again we use the same Custom Panel for showing the toppings.</p>
<pre class="brush: xml; title: ; notranslate">
&lt;Grid x:Name=&quot;ContentPanel&quot; Grid.Row=&quot;1&quot; Margin=&quot;12,0,12,0&quot;
              Background=&quot;DarkRed&quot;&gt;
            &lt;Grid.RowDefinitions&gt;
                &lt;RowDefinition/&gt;
                &lt;RowDefinition/&gt;
            &lt;/Grid.RowDefinitions&gt;
            &lt;StackPanel BindingValidationError=&quot;ContentPanel_BindingValidationError&quot;&gt;
                &lt;TextBlock Text=&quot;Name&quot; Margin=&quot;10,0,0,0&quot;/&gt;
                &lt;TextBox x:Name=&quot;txtName&quot; InputScope=&quot;PersonalFullName&quot; Text=&quot;{Binding DeliveryAddress.Name, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}&quot;/&gt;
                &lt;TextBlock Text=&quot;Address&quot; Margin=&quot;10,0,0,0&quot;/&gt;
                &lt;TextBox x:Name=&quot;txtAddress1&quot; InputScope=&quot;PostalAddress&quot; Text=&quot;{Binding DeliveryAddress.AddressLine1, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}&quot;/&gt;
                &lt;TextBlock Text=&quot;City, State&quot; Margin=&quot;10,0,0,0&quot;/&gt;
                &lt;TextBox x:Name=&quot;txtAddress2&quot; InputScope=&quot;PostalAddress&quot; Text=&quot;{Binding DeliveryAddress.AddressLine2, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True}&quot;/&gt;
            &lt;/StackPanel&gt;
            &lt;Grid x:Name=&quot;SelectedCrust&quot; Grid.Row=&quot;1&quot;&gt;
                &lt;Grid.ColumnDefinitions&gt;
                    &lt;ColumnDefinition Width=&quot;Auto&quot;/&gt;
                    &lt;ColumnDefinition/&gt;
                &lt;/Grid.ColumnDefinitions&gt;
                &lt;Grid.RowDefinitions&gt;
                    &lt;RowDefinition/&gt;
                    &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                &lt;/Grid.RowDefinitions&gt;
                &lt;Image Source=&quot;{Binding ItemImage}&quot; Width=&quot;216&quot; Height=&quot;156&quot; Margin=&quot;0, -80, 0, 0&quot;/&gt;
                &lt;ItemsControl x:Name=&quot;lstSelectedToppingsImg&quot;&gt;
                    &lt;ItemsControl.ItemsPanel&gt;
                        &lt;ItemsPanelTemplate&gt;
                            &lt;local:CustomPanel Background=&quot;Transparent&quot;/&gt;
                        &lt;/ItemsPanelTemplate&gt;
                    &lt;/ItemsControl.ItemsPanel&gt;
                    &lt;ItemsControl.ItemTemplate&gt;
                        &lt;DataTemplate&gt;
                            &lt;Image Source=&quot;{Binding ItemImage}&quot; Width=&quot;226&quot; Height=&quot;156&quot;/&gt;
                        &lt;/DataTemplate&gt;
                    &lt;/ItemsControl.ItemTemplate&gt;
                &lt;/ItemsControl&gt;
                                                                       
                &lt;StackPanel  Grid.Column=&quot;1&quot; Margin=&quot;0,15,0,0&quot;&gt;
                    &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
                        &lt;TextBlock Text=&quot;{Binding ItemName}&quot; HorizontalAlignment=&quot;Center&quot; 
                            VerticalAlignment=&quot;Top&quot; FontWeight=&quot;Bold&quot;/&gt;
                        &lt;TextBlock Text=&quot; Pizza with&quot;&gt;&lt;/TextBlock&gt;
                    &lt;/StackPanel&gt;                    
                    &lt;ListBox x:Name=&quot;lstSelectedToppings&quot; Margin=&quot;0,5,0,0&quot;&gt;
                        &lt;ListBox.ItemTemplate&gt;
                            &lt;DataTemplate&gt;
                                &lt;StackPanel Orientation=&quot;Horizontal&quot;&gt;
                                    &lt;TextBlock Text=&quot;{Binding}&quot;
                                           FontSize=&quot;18&quot;/&gt;
                                    &lt;TextBlock Text=&quot;.&quot; FontSize=&quot;18&quot; VerticalAlignment=&quot;Center&quot;/&gt;
                                &lt;/StackPanel&gt;
                            &lt;/DataTemplate&gt;
                        &lt;/ListBox.ItemTemplate&gt;
                        &lt;ListBox.ItemsPanel&gt;
                            &lt;ItemsPanelTemplate&gt;                                
                                &lt;toolkit:WrapPanel MaxWidth=&quot;220&quot;/&gt;
                            &lt;/ItemsPanelTemplate&gt;
                        &lt;/ListBox.ItemsPanel&gt;
                    &lt;/ListBox&gt;
                &lt;/StackPanel&gt;
                &lt;Button Content=&quot;Place Order&quot; Grid.Row=&quot;1&quot; Grid.ColumnSpan=&quot;2&quot; Width=&quot;200&quot;
                        Click=&quot;Button_Click&quot;/&gt;
            &lt;/Grid&gt;
        &lt;/Grid&gt;
</pre>
<p>Similar to what we did in Toppings Selection screen, update the data context in the method OnNavigatedTo and process the order when clicked on ‘Place Order’.</p>
<pre class="brush: csharp; title: ; notranslate">
protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string selectedIndex = &quot;&quot;;
            if (NavigationContext.QueryString.TryGetValue(&quot;selectedItem&quot;, out selectedIndex))
            {
                int index = int.Parse(selectedIndex);
                SelectedCrust.DataContext = App.ViewModel.CrustItems[index];
                lstSelectedToppings.ItemsSource = lstSelectedToppingsImg.ItemsSource = null;
                lstSelectedToppings.ItemsSource = from p in App.ViewModel.Toppings
                                                  where p.IsSelected == true
                                                  select p.ItemName;
                lstSelectedToppingsImg.ItemsSource = from p in App.ViewModel.Toppings
                                                     where p.IsSelected == true
                                                     select p; 
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(txtName.Text.Trim()))
                MessageBox.Show(&quot;Name cannot be empty&quot;);
            else if (string.IsNullOrEmpty(txtAddress1.Text.Trim()))
                MessageBox.Show(&quot;Address line 1 cannot be empty&quot;);
            else if (string.IsNullOrEmpty(txtAddress2.Text.Trim()))
                MessageBox.Show(&quot;Address line 2 cannot be empty&quot;);
            else
                ProcessOrder();            
        }

        private void ProcessOrder()
        {
            Random rndConfirm = new Random(1000);
            MessageBox.Show(&quot;Thanks for placing the order. Your order confirmation number: &quot; + rndConfirm.Next().ToString());
            NavigationService.Navigate(new Uri(&quot;/MainPage.xaml&quot;, UriKind.Relative));
        }
</pre>
<h3>Conclusion</h3>
<p>In Process Order, we generate a random order number, clear the selections and navigate back to the MainPage. Ideally, we should store the order number and send a e-mail confirmation.</p>
<p>In next post, we will see how to connect this to a OData service instead of hard-coded data.</p>
<p><a href="http://www.chaitanyavenneti.com/downloads/OrderPizza.zip">Click here</a> to download the source code.</p>
<p>Happy Coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/wp7-pizza-app-ui/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Creating a Custom Panel in Silverlight</title>
		<link>http://www.chaitanyavenneti.com/topics/custom-panel-in-silverlight/</link>
		<comments>http://www.chaitanyavenneti.com/topics/custom-panel-in-silverlight/#comments</comments>
		<pubDate>Wed, 20 Jul 2011 15:16:12 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Topics]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Custom Panel]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1222</guid>
		<description><![CDATA[Silverlight allows StackPanel and WrapPanel to be used as items panels in a ItemsPanelTemplate, for controls like ListBox where a collection of items are shown. Sometimes we need to create a custom panel where the out-of-box panels may not full-fill the need. I came across one such situation where I need to show the items ]]></description>
			<content:encoded><![CDATA[<p>Silverlight allows StackPanel and WrapPanel to be used as items panels in a ItemsPanelTemplate, for controls like ListBox where a collection of items are shown.</p>
<p>Sometimes we need to create a custom panel where the out-of-box panels may not full-fill the need. I came across one such situation where I need to show the items layered over one another.</p>
<p>It&#8217;s a Windows Phone 7 Pizza application, where user can choose the toppings, which are shown on top of a Pizza as if its a real one.</p>
<p><span id="more-1222"></span></p>
<p>I used the following approach to show toppings on a pizza base.</p>
<ul>
<li>Use an Image control to show the base.</li>
<li>Place an ItemsControl with images at Z-index as the Image Control.</li>
</ul>
<p>The following is the xaml code,</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/code_stackpanel.png" rel="wp-prettyPhoto[g1222]"><img class="aligncenter size-full wp-image-1224" title="code_stackpanel" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/code_stackpanel.png" alt="" width="556" height="240" /></a></p>
<p>Which resulted in the following output,</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/toppings_1.jpg" rel="wp-prettyPhoto[g1222]"><img class="aligncenter size-full wp-image-1223" title="Toppings_Stacked" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/toppings_1.jpg" alt="" width="318" height="557" /></a></p>
<p>In ordered to layer the topping images on one another, we need to change the ItemsPanel from StackPanel to a CustomPanel which removes the spacing between the collection items.</p>
<h3>Creating the Custom Panel</h3>
<p>Create a new class derived from <strong>Panel</strong>.</p>
<pre class="brush: csharp; title: ; notranslate">
    public class CustomPanel : Panel
    {
        public CustomPanel() : base()
        {

        }
    }
</pre>
<p>All that&#8217;s required is to,</p>
<ol>
<li>Override the <strong>MeasureOverride</strong> method to influence the size of the child elements.</li>
<li>Override the <strong>ArrangeOverride</strong> method to influence the position of the child elements in the panel.</li>
</ol>
<div>The following code shows MeasureOverride,</div>
<div>
<pre class="brush: csharp; title: ; notranslate">
     protected override Size MeasureOverride(Size availableSize)
        {
            Size availableSpace = new Size(double.PositiveInfinity, double.PositiveInfinity);
            Size desiredSize = new Size(0, 0);

            foreach (UIElement child in this.Children)
            {
                child.Measure(availableSpace);
                desiredSize.Width = Math.Max(desiredSize.Height, child.DesiredSize.Width);
                desiredSize.Height = Math.Max(desiredSize.Height, child.DesiredSize.Height);
            }
            return desiredSize;
        }
</pre>
</div>
<div>The following code shows ArrangeOverride, where all the child items are given a starting point (0, 0), such that every element is positioned at the same place in the panel.</div>
<div>
<pre class="brush: csharp; title: ; notranslate">
     protected override Size ArrangeOverride(Size finalSize)
        {
            Size returnSize = finalSize;
            //The location where the child will be displayed
            foreach (FrameworkElement child in Children)
            {
                Point location = new Point(0, 0);
                child.Arrange(new Rect(location, child.DesiredSize));

                returnSize.Width = Math.Max(returnSize.Height, child.DesiredSize.Width);
                returnSize.Height = Math.Max(returnSize.Height, child.DesiredSize.Height);
            }
            //Return the total size used
            return returnSize;
        }
</pre>
</div>
<div>Now let&#8217;s change the ItemsPanel to our Custom Panel,</div>
<p></p>
<div><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/code_custompanel.png" rel="wp-prettyPhoto[g1222]"><img class="aligncenter size-full wp-image-1225" title="code_custompanel" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/code_custompanel.png" alt="" width="552" height="238" /></a></div>
<p></p>
<div>And here is the output,</div>
<p></p>
<div><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Toppings.png" rel="wp-prettyPhoto[g1222]"><img class="aligncenter size-full wp-image-1226" title="Toppings" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Toppings.png" alt="" width="317" height="531" /></a></div>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/custom-panel-in-silverlight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introduction to WP7 Databound Application</title>
		<link>http://www.chaitanyavenneti.com/topics/wp7-databound-app-intro/</link>
		<comments>http://www.chaitanyavenneti.com/topics/wp7-databound-app-intro/#comments</comments>
		<pubDate>Mon, 11 Jul 2011 11:56:59 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Topics]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Windows Phone 7]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1136</guid>
		<description><![CDATA[This tutorial is part of the WP7 Databound Application series. Read Part II, Creating the Pizza App User Interface (Opens in a new window) In this tutorial, We will see what a Windows Phone 7 databound application is and how to create one. Specifically, we will create a simple pizza ordering application using a Windows Phone ]]></description>
			<content:encoded><![CDATA[<p>This tutorial is part of the WP7 Databound Application series.</p>
<p>Read Part II, <a title="Pizza App UI Design" href="http://www.chaitanyavenneti.com/topics/wp7-pizza-app-ui/" target="_blank">Creating the Pizza App User Interface</a> (Opens in a new window)</p>
<p>In this tutorial, We will see what a Windows Phone 7 databound application is and how to create one. Specifically, we will create a simple pizza ordering application using a Windows Phone 7 databound project.</p>
<h2>What is a databound application?</h2>
<p>A databound application generates an application in a Model/View/ViewModel (MVVM) style, with sample data exposed in ViewModel classes. It creates a master view and details view which were bound to respective view models.</p>
<h2>Why should I use a databound application?</h2>
<p>When you create a databound application, it creates the pages with properly hooked up navigation and basic data usage, this includes both design time and run time data. Which means, you can see how the page looks without the need to run the simulator.</p>
<p>All you have to do is focus on your application logic.</p>
<p><span id="more-1136"></span></p>
<h3><span style="font-size: 20px;">Create a New Project</span></h3>
<p>Open Visual Studio. Go to File -&gt; New -&gt; Project.<br />
Under &#8216;Installed Templates&#8217;, go to &#8216;Silverlight for Windows Phone&#8217; and select &#8216;Windows Phone Databound Application&#8217;.</p>
<div id="attachment_1139" class="wp-caption aligncenter" style="width: 623px"><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/04/new-project.png" rel="wp-prettyPhoto[g1136]"><img class="size-full wp-image-1139   " title="Create New Databound Application" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/04/new-project.png" alt="Windows Phone 7 Databound Application Template" width="613" height="394" /></a>
<p class="wp-caption-text">Windows Phone 7 Databound Application Template</p>
</div>
<p>Name the solution as &#8216;OrderPizza&#8217; and Click &#8216;Ok&#8217;. This will create a windows phone databound application.</p>
<p>Notice in the &#8216;Solution Explorer&#8217; that Visual Studio already created the Views, ViewModel and Sample data.</p>
<div id="attachment_1188" class="wp-caption aligncenter" style="width: 298px"><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Solution_Explorer.png" rel="wp-prettyPhoto[g1136]"><img class="size-full wp-image-1188" title="Solution Explorer" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Solution_Explorer.png" alt="Solution Explorer" width="288" height="350" /></a>
<p class="wp-caption-text">Solution Explorer</p>
</div>
<p>Now let&#8217;s hit &#8216;F5&#8242;, and see the application running.</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Master_Details.png" rel="wp-prettyPhoto[g1136]"><img class="aligncenter size-full wp-image-1190" title="Master_Details" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/Master_Details.png" alt="Master List View and Details View" width="639" height="524" /></a></p>
<p>The application loads with the &#8216;MainPage&#8217; showing the items from the view model. Clicking on any item will load &#8216;DetailsPage&#8217; showing the item&#8217;s details.</p>
<p>Now let&#8217;s inspect the xaml pages, MainPage.xaml and DetailsPage.xaml, to see how the items were loaded.</p>
<h3>MainPage.xaml</h3>
<p>MainPage.xaml contains a ListBox with the ItemsSource set to &#8216;Items&#8217; property and each list item having two TextBlock controls bound the properties LineOne and LineTwo.<br />
<a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/mainpage_code11.png" rel="wp-prettyPhoto[g1136]"><img class="aligncenter size-full wp-image-1198" title="MainPage List Code Snippet" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/mainpage_code11.png" alt="MainPage List Code Snippet" width="581" height="213" /></a><strong></strong></p>
<h3>DetailsPage.xaml</h3>
<p>DetailsPage.xaml shows the selected item name and items details in two TextBlock controls bound to the properties LineOne and LineThree.<br />
<a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/DetailsList_code1.png" rel="wp-prettyPhoto[g1136]"><img class="aligncenter size-full wp-image-1199" title="Item Detail Code Snippet" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/07/DetailsList_code1.png" alt="Item Detail Code Snippet" width="486" height="166" /></a></p>
<h3>The View Model</h3>
<p>Let&#8217;s see what the view model contains and how the data is loaded in the views.<br />
The MainViewModel.cs contains a list of items of type ItemViewModel.</p>
<pre class="brush: csharp; title: ; notranslate">
public MainViewModel()
{
     this.Items = new ObservableCollection();
}
</pre>
<p><strong>ItemViewModel</strong> contains three string properties namely <em>LineOne, LineTwo</em> and <em>LineThree</em>.</p>
<p>The method <strong>LoadData</strong> is where the dummy data is created.</p>
<pre class="brush: csharp; title: ; notranslate">
public void LoadData()
        {
            // Sample data; replace with real data
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime one&quot;, LineTwo = &quot;Maecenas praesent accumsan bibendum&quot;, LineThree = &quot;Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime two&quot;, LineTwo = &quot;Dictumst eleifend facilisi faucibus&quot;, LineThree = &quot;Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime three&quot;, LineTwo = &quot;Habitant inceptos interdum lobortis&quot;, LineThree = &quot;Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime four&quot;, LineTwo = &quot;Nascetur pharetra placerat pulvinar&quot;, LineThree = &quot;Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime five&quot;, LineTwo = &quot;Maecenas praesent accumsan bibendum&quot;, LineThree = &quot;Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime six&quot;, LineTwo = &quot;Dictumst eleifend facilisi faucibus&quot;, LineThree = &quot;Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime seven&quot;, LineTwo = &quot;Habitant inceptos interdum lobortis&quot;, LineThree = &quot;Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime eight&quot;, LineTwo = &quot;Nascetur pharetra placerat pulvinar&quot;, LineThree = &quot;Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime nine&quot;, LineTwo = &quot;Maecenas praesent accumsan bibendum&quot;, LineThree = &quot;Facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime ten&quot;, LineTwo = &quot;Dictumst eleifend facilisi faucibus&quot;, LineThree = &quot;Suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime eleven&quot;, LineTwo = &quot;Habitant inceptos interdum lobortis&quot;, LineThree = &quot;Habitant inceptos interdum lobortis nascetur pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime twelve&quot;, LineTwo = &quot;Nascetur pharetra placerat pulvinar&quot;, LineThree = &quot;Ultrices vehicula volutpat maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime thirteen&quot;, LineTwo = &quot;Maecenas praesent accumsan bibendum&quot;, LineThree = &quot;Maecenas praesent accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime fourteen&quot;, LineTwo = &quot;Dictumst eleifend facilisi faucibus&quot;, LineThree = &quot;Pharetra placerat pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime fifteen&quot;, LineTwo = &quot;Habitant inceptos interdum lobortis&quot;, LineThree = &quot;Accumsan bibendum dictumst eleifend facilisi faucibus habitant inceptos interdum lobortis nascetur pharetra placerat&quot; });
            this.Items.Add(new ItemViewModel() { LineOne = &quot;runtime sixteen&quot;, LineTwo = &quot;Nascetur pharetra placerat pulvinar&quot;, LineThree = &quot;Pulvinar sagittis senectus sociosqu suscipit torquent ultrices vehicula volutpat maecenas praesent accumsan bibendum&quot; });

            this.IsDataLoaded = true;
        }
</pre>
<p>The view model is created and loaded from App.xaml.cs as shown,</p>
<pre class="brush: csharp; title: ; notranslate">
public static MainViewModel ViewModel
        {
            get
            {
                // Delay creation of the view model until necessary
                if (viewModel == null)
                    viewModel = new MainViewModel();

                return viewModel;
            }
        }
private void Application_Activated(object sender, ActivatedEventArgs e)
        {
            // Ensure that application state is restored appropriately
            if (!App.ViewModel.IsDataLoaded)
            {
                App.ViewModel.LoadData();
            }
        }
</pre>
<h3>Conclusion</h3>
<p>Now that you have understood how a databound application works, in next post we&#8217;ll see how to convert this into a real world Pizza Ordering application.</p>
<p>Read Part II, <a href="http://www.chaitanyavenneti.com/topics/wp7-pizza-app-ui/">Creating the Pizza App User Interface</a>.</p>
<p>Happy Coding!</p>
<p>http://www.chaitanyavenneti.com/topics/wp7-pizza-app-ui/</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/wp7-databound-app-intro/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Windows Azure Storage Constraints</title>
		<link>http://www.chaitanyavenneti.com/topics/windows-azure-storage-constraints/</link>
		<comments>http://www.chaitanyavenneti.com/topics/windows-azure-storage-constraints/#comments</comments>
		<pubDate>Tue, 28 Jun 2011 13:01:20 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Topics]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1178</guid>
		<description><![CDATA[Tables and Queues in Windows Azure play a vital role in storage. The following are the constraints that need to be considered while using tables and queues in Azure, Constraints on Data types String &#8211; 64 kb max Binary &#8211; 64 kb max Constraints on Field/Row Size Maximum number of fields &#8211; 255 Partition Key ]]></description>
			<content:encoded><![CDATA[<p>Tables and Queues in Windows Azure play a vital role in storage.</p>
<p>The following are the constraints that need to be considered while using tables and queues in Azure,</p>
<p><strong>Constraints on Data types</strong></p>
<p>String &#8211; 64 kb max</p>
<p>Binary &#8211; 64 kb max</p>
<p><strong>Constraints on Field/Row Size </strong></p>
<p>Maximum number of fields &#8211; 255</p>
<p>Partition Key &#8211; Less than 1 kb</p>
<p>Row + Partition &#8211; Less than 256 char</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/windows-azure-storage-constraints/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight Tip: RadioButton/CheckBox Binding ClickMode</title>
		<link>http://www.chaitanyavenneti.com/topics/silverlight-tip-radiobuttoncheckbox-binding-clickmode/</link>
		<comments>http://www.chaitanyavenneti.com/topics/silverlight-tip-radiobuttoncheckbox-binding-clickmode/#comments</comments>
		<pubDate>Wed, 11 May 2011 18:42:28 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Topics]]></category>
		<category><![CDATA[Tutorials]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=1161</guid>
		<description><![CDATA[No doubt that Binding in Silverlight is a powerful feature. There are few caveats when considering RadioButton or CheckBox like controls. The following code snippet is a common scenario where a RadioButton or CheckBox can be used with data binding. Let&#8217;s consider a situation where you want to show a list of options to choose ]]></description>
			<content:encoded><![CDATA[<p>No doubt that Binding in Silverlight is a powerful feature. There are few caveats when considering RadioButton or CheckBox like controls.<br />
The following code snippet is a common scenario where a RadioButton or CheckBox can be used with data binding.</p>
<pre class="brush: xml; title: ; notranslate">
 &lt;ItemsControl&gt;
            &lt;ItemsControl.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;RadioButton Content=&quot;{Binding ItemName}&quot; IsChecked=&quot;{Binding IsSelected, Mode=TwoWay}&quot;/&gt;
                &lt;/DataTemplate&gt;
            &lt;/ItemsControl.ItemTemplate&gt;
 &lt;/ItemsControl&gt;
</pre>
<p><span id="more-1161"></span>Let&#8217;s consider a situation where you want to show a list of options to choose from for the user. And whenever a selection is made, you want to perform a certain kind of actions.<br />
In that case you may change the code something similar to,</p>
<pre class="brush: xml; title: ; notranslate">
   &lt;ItemsControl&gt;
            &lt;ItemsControl.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;RadioButton Content=&quot;{Binding ItemName}&quot; IsChecked=&quot;{Binding IsSelected, Mode=TwoWay}&quot;
                                 Checked=&quot;RadioButton_Checked&quot;/&gt;
                &lt;/DataTemplate&gt;
            &lt;/ItemsControl.ItemTemplate&gt;
   &lt;/ItemsControl&gt;
</pre>
<p>And in the RadioButton&#8217;s Checked event handler you may want to do some kind of action based on the <strong>IsSelected</strong> value. Now if you try to read the value of <strong>IsSelected</strong> in the event handler, you&#8217;ll still see it as <strong>False</strong>.</p>
<p>This is because the value of the binding property will be updated only after completing the cycle of UnChecked and Checked events.<br />
To make sure of the binding property is updated, you can use the property <strong>ClickMode</strong>, exists for both RadioButton and CheckBox.</p>
<p>ClickMode takes the following three values,<a href="http://www.chaitanyavenneti.com/wp-content/uploads/2011/05/clickmode.png" rel="wp-prettyPhoto[g1161]"><img class="aligncenter size-full wp-image-1167" title="clickmode" src="http://www.chaitanyavenneti.com/wp-content/uploads/2011/05/clickmode.png" alt="" width="198" height="105" /></a></p>
<p>Now let&#8217;s Change the Xaml as follows,</p>
<pre class="brush: xml; title: ; notranslate">
&lt;ItemsControl.ItemTemplate&gt;
                &lt;DataTemplate&gt;
                    &lt;RadioButton Content=&quot;{Binding ItemName}&quot; IsChecked=&quot;{Binding IsSelected, Mode=TwoWay}&quot;
                                 Click=&quot;RadioButton_Click&quot; ClickMode=&quot;Release&quot;/&gt;
                &lt;/DataTemplate&gt;
&lt;/ItemsControl.ItemTemplate&gt;
</pre>
<p>Note that we have changed the event handler to <strong>Click</strong> from <strong>Checked</strong> and set the <strong>ClickMode</strong> to Release.</p>
<p>Now if you read <strong>IsSelected</strong> in the Click handler, you&#8217;ll get the exact value.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/topics/silverlight-tip-radiobuttoncheckbox-binding-clickmode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight Password Strength Checker &#8211; Part 1 of 3</title>
		<link>http://www.chaitanyavenneti.com/silverlight/silverlight-password-strength-checker-part-1-of-3-2/</link>
		<comments>http://www.chaitanyavenneti.com/silverlight/silverlight-password-strength-checker-part-1-of-3-2/#comments</comments>
		<pubDate>Wed, 15 Dec 2010 18:10:06 +0000</pubDate>
		<dc:creator>Chaitanya Venneti</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Custom Controls]]></category>
		<category><![CDATA[Password Strength]]></category>

		<guid isPermaLink="false">http://www.chaitanyavenneti.com/?p=83</guid>
		<description><![CDATA[Introduction In this 3 part series, we are going to learn how to create a custom control, the parts and states of custom control and skinning. We will create a simple password strength checker, which will tell how strong your password is. In part 1, we will see how to create a fully usable custom ]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>In this 3 part series, we are going to learn how to create a custom control, the parts and states of custom control and skinning. We will create a simple password strength checker, which will tell how strong your password is. In part 1, we will see how to create a fully usable custom control.</p>
<p><strong>Overview</strong></p>
<p>A Custom Control is same as any other User Control except the fact that it comes with the power of editable Styles and Templates. For more details, see <a href="http://msdn.microsoft.com/en-us/library/cc278068(v=VS.95).aspx">Control Customization</a> on MSDN.</p>
<div><strong>You Will Learn</strong></div>
<ul>
<li>What is a Silverlight Class Library</li>
<li>How to create a Custom Control using a Class Library</li>
<li>How to create properties that can be accessed both from Xaml and code-behind</li>
</ul>
<p>Before going further, let&#8217;s have a look at what we are going to create.</p>
<p><span id="more-83"></span></p>
<div id="scid:CFEDF738-22D6-410b-9F8B-86DC19B18415:c79c399f-7f67-43cb-a325-09b13decfd19" class="wlWriterEditableSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;">
<div id="silverlightControlHost"><object width="600" height="200" data="data:application/x-silverlight-2," type="application/x-silverlight-2"><param name="source" value="http://www.chaitanyavenneti.com/wp-content/uploads/images/SL_PasswordStrength.xap" /><param name="background" value="white" /><param name="minRuntimeVersion" value="4.0" /><param name="autoupgrade" value="true" /><param name="enableHtmlAccess" value="true" /><a style="text-decoration: none;" href="http://go.microsoft.com/fwlink/?LinkID=149156"><img style="border-style: none; width: 400px; height: 200px;" src="http://storage.timheuer.com/sl4wp-ph.png" alt="Install Microsoft Silverlight" /></a></object></div>
</div>
<div class="wlWriterSmartContent" style="margin: 0px; display: inline; float: none; padding: 0px;"><strong>Creating The Solution</strong></div>
<p>1. Open Visual Studio and create a new Silverlight Application, name it <strong>SilverlightPasswordStrength</strong>.</p>
<p>2. In MainPage.xaml, add the following row definitions to the Grid,</p>
<pre class="brush: xml; title: ; notranslate">
&lt;Grid.RowDefinitions&gt;
    &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
    &lt;RowDefinition Height=&quot;*&quot;/&gt;
&lt;/Grid.RowDefinitions&gt;
</pre>
<p>3. Add a TextBlock to the first row,</p>
<pre class="brush: xml; title: ; notranslate">&lt;TextBlock Text=&quot;Silverlight Password Strength Demo&quot; HorizontalAlignment=&quot;Center&quot; Margin=&quot;0,15,0,0&quot; FontSize=&quot;16&quot; FontWeight=&quot;Bold&quot;/&gt;</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->4. And add a StackPanel with another TextBlock and a PasswordBox to the second row,</p>
<pre class="brush: xml; title: ; notranslate">

&lt;StackPanel Orientation=&quot;Horizontal&quot; VerticalAlignment=&quot;Top&quot;
HorizontalAlignment=&quot;Center&quot; Grid.Row=&quot;1&quot; Margin=&quot;0,50,0,0&quot;&gt;

&lt;TextBlock Text=&quot;Password&quot; VerticalAlignment=&quot;Center&quot; FontWeight=&quot;Normal&quot; Foreground=&quot;#FF2E2E2E&quot; FontFamily=&quot;Portable User Interface&quot;
 FontSize=&quot;13&quot; TextAlignment=&quot;Left&quot;/&gt;

&lt;PasswordBox x:Name=&quot;pwdPassword&quot; Width=&quot;200&quot; Height=&quot;35&quot; Margin=&quot;5,0,0,0&quot;/&gt;

&lt;/StackPanel&gt;

</pre>
<p>By now, your UI should look like this,</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/images/SilverlightPasswordStrengthCheckerPart1o_14BF7/image.png" rel="wp-prettyPhoto[g83]"><img style="display: inline; border-width: 0px;" title="image" src="http://www.chaitanyavenneti.com/wp-content/uploads/images/SilverlightPasswordStrengthCheckerPart1o_14BF7/image_thumb.png" border="0" alt="image" width="343" height="164" /></a></p>
<p><strong>Creating The Custom Control</strong></p>
<p>1. Add a new Silverlight Class Library to the solution, name it <strong>PasswordStrengthChecker</strong>.</p>
<p>2. Rename the Class1.cs to PasswordStrengthChecker.cs, and derive it from <strong>Control</strong>.</p>
<pre class="brush: csharp; title: ; notranslate">
public class PasswordStrengthChecker : Control
{

//...

}

</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->3. Right-click on the project and select add new folder. Name it <strong>Themes</strong>.</p>
<p>4. Right-click on the Themes folder and select ‘Add New Item’. Add a new Xml File and name it<strong> generic.xaml</strong>.</p>
<p>Now, your Solution Explorer should look like this,</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/images/SilverlightPasswordStrengthCheckerPart1o_14BF7/image_3.png" rel="wp-prettyPhoto[g83]"><img style="display: inline; border-width: 0px;" title="image" src="http://www.chaitanyavenneti.com/wp-content/uploads/images/SilverlightPasswordStrengthCheckerPart1o_14BF7/image_thumb_3.png" border="0" alt="image" width="254" height="337" /></a></p>
<blockquote><p>A Custom Control requires a control class and the default control template. You can place the control class in any code file template in your Silverlight class library. The control template must be placed in a file named <strong>generic.xaml</strong>. If your class library contains multiple controls, all of their default templates must be placed in the same generic.xaml file.</p></blockquote>
<p><strong>Creating the Control Template</strong></p>
<p>The generic.xaml file holds a resource dictionary with a style for each custom control. The style must set the Template property of the corresponding control to apply the default control template.</p>
<p>1. In the generic.xaml file, declare a resource dictionary and Map the project namespace to an XML namespace prefix, so you can access your custom control in your markup.</p>
<div class="csharpcode">
<pre class="brush: xml; title: ; notranslate">
&lt;ResourceDictionary xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot; 
xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot; 
xmlns:local=&quot;clr-namespace:PasswordStrengthChecker&quot;&gt; 
&lt;!--Resource Dictionary Content--&gt;
&lt;/ResourceDictionary&gt;
</pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>2. Inside the ResourceDictionary, define the style for the control.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;Style TargetType=&quot;local:PasswordStrengthChecker&quot;&gt;

&lt;Setter Property=&quot;Template&quot;&gt;

	 &lt;Setter.Value&gt;

	 &lt;ControlTemplate TargetType=&quot;local:PasswordStrengthChecker&quot;&gt;

				&lt;!--Template Content--&gt;

	 &lt;/ControlTemplate&gt;

 &lt;/Setter.Value&gt;

&lt;/Setter&gt;

&lt;/Style&gt;

</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->3. For now let’s define a simple template with a <strong>Border</strong> and <strong>ContentControl</strong>.</p>
<pre class="brush: xml; title: ; notranslate">

&lt;Style TargetType=&quot;local:PasswordStrengthChecker&quot;&gt;

&lt;Setter Property=&quot;Template&quot;&gt;

&lt;Setter.Value&gt;

&lt;ControlTemplate TargetType=&quot;local:PasswordStrengthChecker&quot;&gt;

&lt;Grid&gt;

&lt;Border BorderBrush=&quot;Black&quot; BorderThickness=&quot;1&quot;&gt;

 &lt;ContentPresenter x:Name=&quot;ContentElement&quot; HorizontalAlignment=&quot;Center&quot; VerticalAlignment=&quot;Center&quot;/&gt;

&lt;/Border&gt;

&lt;/Grid&gt;

&lt;/ControlTemplate&gt;

&lt;/Setter.Value&gt;

&lt;/Setter&gt;

&lt;/Style&gt;

</pre>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->ContentElement is our content holder where we will show the required information, in this case the password strength.</p>
<p><strong>Defining The Properties</strong></p>
<p>1. Go to PasswordStrengthChecker class and in the constructor set the <strong>DefaultStyleKey</strong> property.</p>
<pre class="brush: csharp; title: ; notranslate">

public PasswordStrengthChecker()

{

DefaultStyleKey = typeof(PasswordStrengthChecker);

}

</pre>
<blockquote><p>The DefaultStyleKey tells the control to pick up the default style from the generic.xaml file. DefaultStyleKey indicates the type that is used to look up the style.</p></blockquote>
<p>2. The first property we need is the PasswordBox control for which we need to calculate the password strength. Add the following DependencyProperty, which can take a PasswordBox.</p>
<pre class="brush: csharp; title: ; notranslate">

public static readonly DependencyProperty PasswordControlProperty =

	DependencyProperty.Register(&quot;PasswordControl&quot;, typeof(PasswordBox),

		typeof(PasswordStrengthChecker), null);

	public PasswordBox PasswordControl

{

	get		{			return (PasswordBox)base.GetValue(PasswordControlProperty);

	}

		set

	{

			base.SetValue(PasswordControlProperty, value);

	}

	}

</pre>
<div class="csharpcode"></div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->3. Add another read-only property PasswordStrength, using which the calculated password strength can be read.</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum"><pre class="brush: csharp; title: ; notranslate">
&lt;pre&gt;public static readonly DependencyProperty PasswordStrengthProperty =
DependencyProperty.Register(&quot;PasswordStrength&quot;, typeof(string),
typeof(PasswordStrengthChecker), new PropertyMetadata(&quot;Not Valid&quot;));
public string PasswordStrength
{
get { return (string)base.GetValue(PasswordStrengthProperty); }
private set
{
base.SetValue(PasswordStrengthProperty, value);
NotifyPropertyChanged(&quot;PasswordStrength&quot;);
}
}
</pre>
<p></span>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->4. When the control is being initialized, the protected method <strong>OnApplyTemplate</strong> from the base <strong>Control</strong> class will be called. So, let’s override the OnApplyTemplate method to do our initialization activities.</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum"><pre class="brush: csharp; title: ; notranslate">&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;
&lt;pre&gt;  public override void OnApplyTemplate()
  {
       base.OnApplyTemplate();
       //Get the template item named 'ContentElement' and set default value
       (this.GetTemplateChild(&quot;ContentElement&quot;) as ContentPresenter).Content =
                                                              PasswordStrength;
      //If the PasswordBox Control is not null, wire-up the PasswordChanged event
      //where we will calculate the password strength
       if(PasswordControl != null)
       {
            PasswordControl.PasswordChanged += new RoutedEventHandler
                                              (PasswordControl_PasswordChanged);
       }
}&lt;/pre&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;</pre>
<p></span><br />
</span>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<blockquote><p>The <strong>GetTemplatedChild</strong> method is used to find an element from the template with specific name.</p></blockquote>
<p>5. Write the following code, to calculate the password strength and update the content in the template with the calculated value.</p>
<div class="csharpcode">
<pre class="alt"><pre class="brush: csharp; title: ; notranslate">&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;Regex rgLowerCase = new Regex(@&quot;[^a-z]&quot;);&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;Regex rgUpperCase = new Regex(@&quot;[^A-Z]&quot;);&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;Regex rgNumeric = new Regex(@&quot;[^0-9]&quot;);&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;Regex rgSpecialChar = new Regex(@&quot;[/\|_!@#$%^&amp;*()=+.-]&quot;);&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;private void CalculatePasswordStrength(string p)&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;{&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;string[] strengths = new string[6] {&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                               &quot;Very Weak&quot;,&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                               &quot;Weak&quot;,&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                               &quot;Better&quot;,&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                               &quot;Medium&quot;,&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                               &quot;Strong&quot;,&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                               &quot;Very Strong&quot;};&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;    int strength = 0;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;    if (p.Length &gt; 8 )&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;    {&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;       strength++;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;         if (rgLowerCase.IsMatch(p) &amp;&amp; rgUpperCase.IsMatch(p))&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;            strength++;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;            if (rgNumeric.IsMatch(p))&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                 strength++;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                 if (rgSpecialChar.IsMatch(p))&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                     strength++;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                  if (p.Length &gt; 14)&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                      strength++;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;    }&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;      PasswordStrengthValue = strength * 20;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;    PasswordStrength = strengths[strength];&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;      if (string.IsNullOrWhiteSpace(p))&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;        PasswordStrength = &quot;Not Valid&quot;;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;      //Set new strength value to the ContentElement&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;    (this.GetTemplateChild(&quot;ContentElement&quot;) as ContentPresenter).Content =&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;                                                           PasswordStrength;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;   }&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;</pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --><strong>Using The Custom Control</strong></p>
<p>Now our Custom Control is ready. Let’s go back to our <strong>SilverlightPasswordStrength</strong> project and see how we can use this.</p>
<p>1. Right-click on the project and select ‘Add Reference…’. Under <strong>Projects</strong> tab, select <strong>PasswordStrengthChecker</strong>.</p>
<p><a href="http://www.chaitanyavenneti.com/wp-content/uploads/images/SilverlightPasswordStrengthCheckerPart1o_14BF7/image_4.png" rel="wp-prettyPhoto[g83]"><img style="display: inline; border-width: 0px;" title="image" src="http://www.chaitanyavenneti.com/wp-content/uploads/images/SilverlightPasswordStrengthCheckerPart1o_14BF7/image_thumb_4.png" border="0" alt="image" width="427" height="365" /></a></p>
<p>2. In MainPage.xaml, add a new namespace declaration to access the Custom Control.</p>
<div class="csharpcode">
<pre class="alt"><pre class="brush: xml; title: ; notranslate">&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;
&lt;pre&gt;xmlns:tools=&quot;clr-namespace:PasswordStrengthChecker;assembly=PasswordStrengthChecker&quot;
</pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --></p>
<p>3. Create the Custom Control in the StackPanel and set the <strong>PasswordControl</strong> property,</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum"><pre class="brush: xml; title: ; notranslate">&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;
&lt;pre&gt;&lt;StackPanel Orientation=&quot;Horizontal&quot; VerticalAlignment=&quot;Top&quot;
              HorizontalAlignment=&quot;Center&quot; Grid.Row=&quot;1&quot;
              Margin=&quot;0,50,0,0&quot;&gt;
    &lt;TextBlock Text=&quot;Password&quot; VerticalAlignment=&quot;Center&quot; FontWeight=&quot;Normal&quot;
               Foreground=&quot;#FF2E2E2E&quot; FontSize=&quot;13&quot; TextAlignment=&quot;Left&quot;/&gt;
    &lt;PasswordBox x:Name=&quot;pwdPassword&quot; Width=&quot;200&quot; Height=&quot;35&quot; Margin=&quot;5,0,0,0&quot;/&gt;
    &lt;tools:PasswordStrengthChecker x:Name=&quot;pwdChecker&quot; Margin=&quot;10,0,0,0&quot;
             PasswordControl=&quot;{Binding ElementName='pwdPassword'}&quot; Width=&quot;100&quot;/&gt;
&lt;/StackPanel&gt;&lt;/pre&gt;
&lt;/span&gt;&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;&lt;span class=&quot;lnum&quot;&gt;</pre>
<p></span>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } -->As the <strong>PasswordControl</strong> property takes a PasswordBox control, I used Element Binding to provide the control. If you want to set the same property from the code-behind, it should be as follows,</p>
<div class="csharpcode">
<pre class="alt"><pre class="brush: csharp; title: ; notranslate">&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;
&lt;pre&gt;pwdChecker.PasswordControl = pwdPassword;&lt;/pre&gt;
&lt;/pre&gt;
&lt;pre class=&quot;alt&quot;&gt;</pre>
</div>
<p><!--.csharpcode, .csharpcode pre { 	font-size: small; 	color: black; 	font-family: consolas, "Courier New", courier, monospace; 	background-color: #ffffff; 	/*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt  { 	background-color: #f4f4f4; 	width: 100%; 	margin: 0em; } .csharpcode .lnum { color: #606060; } --><em>Run the application and type something in the password box, to see how our custom control behaves.</em></p>
<p><strong>Download:</strong></p>
<p><strong><a title="Click here to download the source" href="http://chaitanyavenneti.com/downloads/SL_PasswordStrength.zip">SL_PasswordStrength (SourceCode)</a></strong></p>
<p><strong>Summary</strong></p>
<p>In Part 1, we learned how to create and use a custom control. In next part, we will see how to add <strong>States and Template Parts</strong> to the custom control.</p>
<p>Thank you for reading, please share your thoughts and suggestions in the Comments section.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.chaitanyavenneti.com/silverlight/silverlight-password-strength-checker-part-1-of-3-2/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
