<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8499391930434267990</id><updated>2011-11-16T13:28:13.893+05:30</updated><category term='C# Classes'/><category term='IIS'/><category term='WPF'/><title type='text'>Siva's dotnet Experiences</title><subtitle type='html'>Somethings are simple... Somethings are complex... Whenever I feels something may help somebody I post it here...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-2368440850287015564</id><published>2010-07-01T23:44:00.000+05:30</published><updated>2010-07-01T23:45:26.537+05:30</updated><title type='text'>OOPS Concept - Rules of Inheritance</title><content type='html'>1. Base class of non-abstract, virtual type.&lt;br /&gt;a. Sub class inherited the base class.&lt;br /&gt;b. Subclass overrides the base class function.&lt;br /&gt;c. Subclass hides the base class function by new keyword.&lt;br /&gt;d. Can’t override or hide a method which is not declared as virtual.&lt;br /&gt;&lt;br /&gt;2. Base Class abstract type&lt;br /&gt;a. Can declare abstract methods, which can’t have any body.&lt;br /&gt;b. Can declare virtual methods which can have body.&lt;br /&gt;c. Can contain non-abstract / virtual methods – simple methods are allowed.&lt;br /&gt;d. All method declared as abstract must be inherited to the base class.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-2368440850287015564?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/2368440850287015564/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2010/07/oops-concept-rules-of-inheritance.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/2368440850287015564'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/2368440850287015564'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2010/07/oops-concept-rules-of-inheritance.html' title='OOPS Concept - Rules of Inheritance'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-2347782113911093828</id><published>2009-12-02T14:54:00.001+05:30</published><updated>2009-12-02T14:54:58.295+05:30</updated><title type='text'>Microsoft SharePoint 2010 Overview Session 1</title><content type='html'>Check out this SlideShare Presentation: &lt;div style="width:425px;text-align:left" id="__ss_2515457"&gt;&lt;a style="font:14px Helvetica,Arial,Sans-serif;display:block;margin:12px 0 3px 0;text-decoration:underline;" href="http://www.slideshare.net/souravnayyar/microsoft-sharepoint-2010-overview-session-1" title="Microsoft SharePoint 2010 Overview Session 1"&gt;Microsoft SharePoint 2010 Overview Session 1&lt;/a&gt;&lt;object style="margin:0px" width="425" height="355"&gt;&lt;param name="movie" value="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=sps2010session1external-091116214154-phpapp02&amp;stripped_title=microsoft-sharepoint-2010-overview-session-1" /&gt;&lt;param name="allowFullScreen" value="true"/&gt;&lt;param name="allowScriptAccess" value="always"/&gt;&lt;embed src="http://static.slidesharecdn.com/swf/ssplayer2.swf?doc=sps2010session1external-091116214154-phpapp02&amp;stripped_title=microsoft-sharepoint-2010-overview-session-1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="355"&gt;&lt;/embed&gt;&lt;/object&gt;&lt;div style="font-size:11px;font-family:tahoma,arial;height:26px;padding-top:2px;"&gt;View more &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/"&gt;presentations&lt;/a&gt; from &lt;a style="text-decoration:underline;" href="http://www.slideshare.net/souravnayyar"&gt;souravnayyar&lt;/a&gt;.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-2347782113911093828?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/2347782113911093828/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/12/microsoft-sharepoint-2010-overview.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/2347782113911093828'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/2347782113911093828'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/12/microsoft-sharepoint-2010-overview.html' title='Microsoft SharePoint 2010 Overview Session 1'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-459219893631209537</id><published>2009-07-14T06:12:00.003+05:30</published><updated>2009-07-14T06:34:08.613+05:30</updated><title type='text'>Exercise for Part -1</title><content type='html'>I think the best thing to do here is, let's say I have some hypothetical layout that I want to achieve. Let's say one of the common layouts, favoured for years where we have a menu bar at the top, followed by a main content area, and a status bar area at the bottom. Let's see a mock up (designed as a simple WinForm) of what we are aiming for:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_izSprwkJon8/SlvYaLEppzI/AAAAAAAAADc/-uiQNns7sEk/s1600-h/WinformExamplewpf.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 242px;" src="http://3.bp.blogspot.com/_izSprwkJon8/SlvYaLEppzI/AAAAAAAAADc/-uiQNns7sEk/s320/WinformExamplewpf.png" alt="" id="BLOGGER_PHOTO_ID_5358114125847832370" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;I think I have given you all the tools you need to carry out designing this sort of layout in WPF. Do you want a hint, I think you will need to use the &lt;code&gt;StackPanel DockPanel Grid&lt;/code&gt; controls in order to get the job done.&lt;br /&gt;&lt;br /&gt;If you're not sure how to do it. I shall give the XAML here below..&lt;br /&gt;&lt;br /&gt;&lt;pre style="margin-top: 0pt;" id="pre16" lang="xml"&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;x:Class&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="WPF_Tour_Beginners_Layout.PuttingItAllTogether"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;WindowStartupLocation&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="CenterScreen"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Title&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="PuttingItAllTogether"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="640"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="480"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;DockPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;LastChildFill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="True"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-comment"&gt;&lt;!--&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span class="code-comment"&gt;Top Menu Area&lt;/span&gt;--&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Menu&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="20"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="#FFA9D1F4"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;DockPanel.Dock&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Top"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-comment"&gt;&lt;!--&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span class="code-comment"&gt; File Menu &lt;/span&gt;--&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="File"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Save"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Separator&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Exit"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-comment"&gt;&lt;!--&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span class="code-comment"&gt; About Menu &lt;/span&gt;--&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Help"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Header&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="About"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;MenuItem&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Menu&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-comment"&gt;&lt;!--&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span class="code-comment"&gt;Bottom Status Bar area, declared before middle section,&lt;br /&gt;       as I want it to fill entire bottom of Window,&lt;br /&gt;       which it wouldn't if there was a Left docked panel before it &lt;/span&gt;--&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="31"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="#FFCAC5C5"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Orientation&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Horizontal"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;DockPanel.Dock&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Bottom"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Label&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="155"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="23"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Status Bar Message...."&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;FontFamily&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Arial"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;FontSize&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-comment"&gt;&lt;!--&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span class="code-comment"&gt;Left Main Content area&lt;/span&gt;--&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="136"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="White"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Button&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="5,5,5,5"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="26"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="button1"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Button&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="126"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="26"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="button2"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="5,5,5,5"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Button&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="126"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="26"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Content&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="button3"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="5,5,5,5"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;StackPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-comment"&gt;&lt;!--&lt;/span&gt;&lt;span class="code-keyword"&gt;&lt;span class="code-comment"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;Right Main Content area, NOTE HOW this Grid is the last child&lt;/span&gt;&lt;br /&gt;      &lt;span style="color: rgb(153, 0, 0);"&gt; so takes all the remaining room &lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Grid&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Auto"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="#FFCC9393"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="*"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="*"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;RowDefinition&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="*"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;                &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;RowDefinition&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="*"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Grid.RowDefinitions&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Aqua"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Row&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="0"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="0"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Aqua"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Row&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="0"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="1"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Aqua"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Row&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="1"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="0"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Aqua"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Row&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="1"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Grid.Column&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="1"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Grid&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;DockPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;p&gt;There are a couple of tricks here, namely the following: &lt;/p&gt;  &lt;ul&gt;&lt;li&gt;The &lt;code&gt;Grid&lt;/code&gt; for the right hand content area, must be the last child declared in order for it to take up the remaining space that the parent &lt;code&gt;DockPanel&lt;/code&gt; wants to fill, due to the &lt;code&gt;LastChildFill=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;True"&lt;/span&gt;&lt;/code&gt; &lt;/li&gt;&lt;li&gt;The &lt;code&gt;StackPanel&lt;/code&gt; used for the status bar, must be before any other child that is declared as being &lt;code&gt;DockPanel.Dock=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Left"&lt;/span&gt;&lt;/code&gt; or &lt;code&gt;DockPanel.Dock=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Right"&lt;/span&gt;&lt;/code&gt;. As if there was another element before the status bar &lt;code&gt;StackPanel&lt;/code&gt;, the status bar &lt;code&gt;StackPanel&lt;/code&gt; would not be able to span the entire width available, as this space would have been stolen by any child that was &lt;code&gt;DockPanel.Dock=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Left"&lt;/span&gt;&lt;/code&gt; or &lt;code&gt;DockPanel.Dock=&lt;span class="code-string"&gt;"&lt;/span&gt;&lt;span class="code-string"&gt;Right"&lt;/span&gt;&lt;/code&gt;. Try it, you'll see what I mean. Simply move the status bar XAML further down in the XAML file, say to the end. &lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h2&gt;Performance Considerations&lt;/h2&gt;  &lt;p&gt;As some panels can be bound to items (this will be discussed further in the &lt;code&gt;DataBinding&lt;/code&gt; article) there may be occasions where the number of children elements displayed in a panel is quite large. For example, if a &lt;code&gt;StackPanel&lt;/code&gt; contains a &lt;code&gt;ListBox&lt;/code&gt; that is bound to a large database query. This would be lots of items, OK in this case it's the &lt;code&gt;ListBox&lt;/code&gt; that will have lots of children. However, internally, the &lt;code&gt;ListBox&lt;/code&gt; control uses a Vertical &lt;code&gt;StackPanel&lt;/code&gt; to render its items by default. Mmmm, that's not so great. &lt;/p&gt;  &lt;p&gt;However all is not that bad, WPF has one further trick up its sleeve to aid in this situation. We can use the dependency/attached property &lt;code&gt;VirtualizingStackPanel.IsVirtualizing&lt;/code&gt; on a &lt;code&gt;ListBox&lt;/code&gt;, which means that the &lt;code&gt;ListBox&lt;/code&gt; controls internal &lt;code&gt;StackPanel&lt;/code&gt; to render its items, will now be virtualized. But what the heck is a &lt;code&gt;vitualizingStackPanel&lt;/code&gt;? &lt;/p&gt;  &lt;p&gt;When a panel is virtualized, it means that only the visible elements are created. The rest aren't displayed. For example, creating a &lt;code&gt;listbox&lt;/code&gt; displaying images bound to a database holding 100,000 rows. This would take a long time for the &lt;code&gt;listbox &lt;/code&gt;to load. If you use a virtualize panel, then only the visible images will get created in the UI. When you scroll down, the currently visible items will get destroyed, and the new visible items will get loaded onto the UI. There is only one panel that supports virtualization and it is the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.windows.controls.virtualizingstackpanel.aspx"&gt;&lt;code&gt;VirtualizingStackPanel&lt;/code&gt;&lt;/a&gt;. If you need to create any new virtualized panels, you will have to write your own.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;I suppose, I hope by now you have the basics of layout in WPF.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-459219893631209537?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/459219893631209537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/07/exercise-for-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/459219893631209537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/459219893631209537'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/07/exercise-for-part-1.html' title='Exercise for Part -1'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_izSprwkJon8/SlvYaLEppzI/AAAAAAAAADc/-uiQNns7sEk/s72-c/WinformExamplewpf.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-1501705244347377919</id><published>2009-07-10T07:13:00.009+05:30</published><updated>2009-07-10T23:46:29.444+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='WPF'/><title type='text'>WPF - Beginners tutorial PART - 1</title><content type='html'>I have started to induct two .NET people. I would prefer to start a series of tutorials at beginner level. I take advantage of Sacha Barber's tutorials in codeproject which got best article award for the month Jasnuary 2008. I thought of starting this PART - 1 with the following topics covered. The list of topics as of now planned are follows...&lt;br /&gt;&lt;br /&gt;* Layout (this article)&lt;br /&gt;* XAML vs Code / Markup Extensions And Resources (next article)&lt;br /&gt;* Commands and Events&lt;br /&gt;* Dependency Properties&lt;br /&gt;* DataBinding&lt;br /&gt;* Styles/Templates&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;&lt;br /&gt;Layout&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Layout is one of the most important parts of any WPF project, the following sub sections will introduce you to the new layout options at your disposal.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;The Importance of Layout&lt;/span&gt;&lt;br /&gt;Layout is a fundamental building block used when writing any WPF. Using the layout controls in WPF allows developers/designers to create very complex arrangements of pages/controls. Without layout, we probably couldn't achieve anything, apart from a mess. So if you are looking for a mess, just quit reading right here. If however you want to know how to use the new layout options in WPF, read on.&lt;br /&gt;&lt;br /&gt;These new layout controls will be the main focus of this article. You are of course free to author your own layout controls, if one of the pre-built controls doesn't suit your needs. We will see more on this later.&lt;br /&gt;&lt;br /&gt;For the purpose of this article, we will be looking at the following:&lt;br /&gt;&lt;br /&gt;* Canvas&lt;br /&gt;* StackPanel&lt;br /&gt;* WrapPanel&lt;br /&gt;* DockPanel&lt;br /&gt;* Grid&lt;br /&gt;&lt;br /&gt;Please note that I will only be covering the basics of these controls, there are many more resources available for being clever with these controls, should you wish to research that. I however, consider the more advanced usages of these controls to be outside the scope of this article. Remember it's a beginner's series, so I want to keep it at a beginner's level.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;A Brief Detour into the Importance of Margin&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;One thing that you simply must know, is how important the Margin property is. By using the Margin, we are able to specify how much space the current control (the one we are specifying the Margin property for), wants to have around it. WPF provides a ValueConverter that accepts a string of the format 5,5,5,5, but what does this mean. Well it's basically saying that we want a Margin of 5 pixels all around the control that is declaring this property. The Margin string, is stating Left, Top, Right, Bottom, and is one of 3 overloaded constructors used by the strangely named Thickness class that is used in the case where we are trying to set the Margin in code behind.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-weight: bold;"&gt;Canvas&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The Canvas control, is one of the easier layout controls to use. It is a simple X/Y position container. Where each of the contained (children) controls must specify the following four properties in order to be positioned within the parent Canvas control:&lt;br /&gt;&lt;br /&gt;* Canvas.Left&lt;br /&gt;* Canvas.Right&lt;br /&gt;* Canvas.Top&lt;br /&gt;* Canvas.Bottom&lt;br /&gt;&lt;br /&gt;With these four properties in place, the control will be positioned using these values within the parent Canvas control. These properties probably look a little bit odd, where we have a Canvas.Left for example, well they are a bit odd actually.&lt;br /&gt;What else do we need to know about a Canvas control and its children. Well actually that's almost it, the only other thing to consider is that if the Canvas control is a simple X/Y position container, what's to stop two child controls, overlapping, and which child control should be on top. Well that's all taken care of by another dependency/attached property of the Canvas control. This is called the Canvas.ZIndex property, and this indicates which control should be on top. Basically the higher the Canvas.ZIndex value is, the more on top the control that declares this dependency/attached property will be. If no Canvas.ZIndex is declared for any of the children controls, the Canvas.ZIndex will be set to the order in which the children are added to the Canvas control.&lt;br /&gt;&lt;br /&gt;Let's see an example of this, shall we? The following picture shows a Canvas control with two children, one on top of the other. This is taken from the file called CanvasDEMO.xaml in the attached demo project.&lt;br /&gt;&lt;br /&gt;In XAML it will be like..&lt;br /&gt;&lt;br /&gt;&lt;pre style="margin-top: 0pt; color: rgb(153, 0, 0);" id="pre0" lang="xml"&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;xmlns&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;xmlns:x&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;x:Class&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;WPF_Tour_Beginners_Layout.CanvasDEMO"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;x:Name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Window"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;Title&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;CanvasDEMO"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;640"&lt;/span&gt; &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;480"&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Canvas&lt;/span&gt; &lt;span class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;0,0,0,0"&lt;/span&gt; &lt;span class="code-attribute"&gt;Background&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;White"&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt; &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Rectangle&lt;/span&gt; &lt;span class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Blue"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Stroke&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Blue"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;145"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;126"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Canvas.Left&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;124"&lt;/span&gt; &lt;span class="code-attribute"&gt;Canvas.Top&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;122"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Ellipse&lt;/span&gt; &lt;span class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Green"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Stroke&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Green"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;121"&lt;/span&gt; &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;100"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Panel.ZIndex&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;1"&lt;/span&gt;&lt;br /&gt;     &lt;span class="code-attribute"&gt;Canvas.Left&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;195"&lt;/span&gt; &lt;span class="code-attribute"&gt;Canvas.Top&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;191"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Canvas&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;And in C#, this would be as follows:&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Canvas canv = new Canvas();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//add the Canvas as sole child of Window&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;this.Content = canv;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;canv.Margin = new Thickness(0, 0, 0, 0);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;canv.Background = new SolidColorBrush(Colors.White);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//The Rectangle&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle r = new Rectangle();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r.Fill = new SolidColorBrush(Colors.Blue);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r.Stroke = new SolidColorBrush(Colors.Blue);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r.Width = 145;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r.Height = 126;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r.SetValue(Canvas.LeftProperty, (double)124);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r.SetValue(Canvas.TopProperty, (double)122);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;canv.Children.Add(r);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;//The Ellipse&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Ellipse el = new Ellipse();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.Fill = new SolidColorBrush(Colors.Green);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.Stroke = new SolidColorBrush(Colors.Green);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.Width = 121;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.Height = 100;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.SetValue(Canvas.ZIndexProperty, 1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.SetValue(Canvas.LeftProperty, (double)195);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;el.SetValue(Canvas.TopProperty, (double)191);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;canv.Children.Add(el);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;And that's about all there is to basic Canvas layout.&lt;br /&gt;I'm not good with VB. If you want to have it in VB, you can try some convertors.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;StackPanel&lt;/h2&gt;  &lt;p&gt;The &lt;code&gt;StackPanel&lt;/code&gt; control is also very easy to use. It simply stacks its contents, vertically or horizontally, using a single property, called &lt;code&gt;Orientation&lt;/code&gt;.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;The following picture shows a &lt;code&gt;WrapPanel&lt;/code&gt; control with 10 children. This is taken from the file called &lt;em&gt;WrapPanelDEMO.xaml&lt;/em&gt;.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_izSprwkJon8/SleCA8LTbVI/AAAAAAAAADE/Ve5Zc20DBuc/s1600-h/WrapPanelDEMO.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 241px;" src="http://4.bp.blogspot.com/_izSprwkJon8/SleCA8LTbVI/AAAAAAAAADE/Ve5Zc20DBuc/s320/WrapPanelDEMO.png" alt="" id="BLOGGER_PHOTO_ID_5356893234445643090" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;Well in XAML, it is as follows:&lt;/p&gt;&lt;pre style="margin-top: 0pt;" id="pre6" lang="xml"&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;xmlns&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;xmlns:x&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;x:Class&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="WPF_Tour_Beginners_Layout.WrapPanelDEMO"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;x:Name&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Window"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Title&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="WrapPanelDEMO"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;WindowStartupLocation&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="CenterScreen"&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="640"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="480"&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;        &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;WrapPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="0,0,0,0"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Background&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="White"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;            &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Rectangle&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Margin&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="10,10,10,10"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="Blue"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Width&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);"&gt; &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-attribute"&gt;Height&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;="60"/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;    &lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;WrapPanel&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;!--&lt;/span--&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span style="color: rgb(0, 0, 0);" class="code-keyword"&gt;&lt;span style="color: rgb(153, 0, 0);"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;And in C#, this would be as follows:&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;WrapPanel wp = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; WrapPanel();&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//add the WrapPanel as sole child of Window&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;this&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.Content = wp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;wp.Margin = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Thickness(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;wp.Background = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.White);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//Add Rectangles&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle r;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;for&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; (&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;int&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; i = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;; i &lt;= &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;10&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;; i++)&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    r = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Rectangle();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    r.Fill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.Blue);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    r.Margin = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Thickness(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;10&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;10&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;10&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;10&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    r.Width = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;60&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    r.Height = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;60&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;    wp.Children.Add(r);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;}&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span style="color: rgb(153, 0, 0);" class="code-keyword"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 0);"&gt;And that's about all there is to basic &lt;/span&gt;&lt;code style="color: rgb(0, 0, 0);"&gt;WrapPanel&lt;/code&gt;&lt;span style="color: rgb(0, 0, 0);"&gt; layout&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/pre&gt;&lt;h2&gt;DockPanel&lt;/h2&gt;  &lt;p&gt;The &lt;code&gt;DockPanel&lt;/code&gt; control is one of the most useful (IMHO) layout controls. It is the one that we would probably use as the base layout control that any new &lt;code&gt;Window&lt;/code&gt; uses. Basically with a &lt;code&gt;DockPanel&lt;/code&gt; control (or 2), we can achieve the sort of layout that has been the main layout for most applications we have ever seen. We can basically get a menu docked to the top, then a left/right main content area, and a status strip at the bottom. This is all thanks to a couple of properties on the &lt;code&gt;DockPanel&lt;/code&gt; control. Basically we can control the docking of any of our child controls that is within a parent &lt;code&gt;DockPanel&lt;/code&gt; control by the use of the following dependency/attached property. &lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;code&gt;DockPanel.Dock&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;This property may be set to Left/Right/Top or Bottom. There is one further property exposed as a normal CLR property on the &lt;code&gt;DockPanel&lt;/code&gt; control which is called &lt;code&gt;LastChildFill&lt;/code&gt; which when set to &lt;code&gt;&lt;span class="code-keyword"&gt;true&lt;/span&gt;&lt;/code&gt; will make the last child control that was added to the &lt;code&gt;DockPanel&lt;/code&gt; control, fill the remaining available space. This will override any &lt;code&gt;DockPanel.Dock&lt;/code&gt; property that the child control may have already set. &lt;/p&gt;  &lt;p&gt;Let's see an example of this, shall we? The following picture shows a &lt;code&gt;DockPanel&lt;/code&gt; control with two children, one docked to the top, and the other docked to fill the remaining available area. This is taken from the file called &lt;em&gt;DockPanelDEMO.xaml&lt;/em&gt; in the attached demo project.&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_izSprwkJon8/SleDAR3Ww0I/AAAAAAAAADM/4KZqaQuqp5Q/s1600-h/DockPanelDEMO.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 240px;" src="http://1.bp.blogspot.com/_izSprwkJon8/SleDAR3Ww0I/AAAAAAAAADM/4KZqaQuqp5Q/s320/DockPanelDEMO.png" alt="" id="BLOGGER_PHOTO_ID_5356894322599314242" border="0" /&gt;&lt;/a&gt;So how does this look in code? Well in XAML, it is as follows:&lt;/p&gt;&lt;pre style="margin-top: 0pt; color: rgb(153, 0, 0);" id="pre9" lang="xml"&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;xmlns&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;xmlns:x&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;x:Class&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;WPF_Tour_Beginners_Layout.DockPanelDEMO"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;x:Name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Window"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;Title&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;DockPanelDEMO"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;WindowStartupLocation&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;CenterScreen"&lt;/span&gt;&lt;br /&gt;&lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;640"&lt;/span&gt; &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;480"&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DockPanel&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Auto"&lt;/span&gt; &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Auto"&lt;/span&gt; &lt;span class="code-attribute"&gt;LastChildFill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;True"&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Rectangle&lt;/span&gt; &lt;span class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;CornflowerBlue"&lt;/span&gt; &lt;span class="code-attribute"&gt;Stroke&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;CornflowerBlue"&lt;/span&gt;&lt;br /&gt;      &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;20"&lt;/span&gt; &lt;span class="code-attribute"&gt;DockPanel.Dock&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Top"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;  &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Rectangle&lt;/span&gt; &lt;span class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Orange"&lt;/span&gt; &lt;span class="code-attribute"&gt;Stroke&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Orange"&lt;/span&gt;  &lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;DockPanel&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;And in C#, this would be as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre style="margin-top: 0pt;" id="pre10" lang="cs"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;DockPanel dp = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; DockPanel();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;dp.LastChildFill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;true&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//this is the same as Width="Auto" in XAML, as long as its not applied&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;to a GridColumn Width/Height /GridRow Width/Height which has special classes&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;dp.Width = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-SDKkeyword"&gt;Double&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.NaN;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;dp.Height = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-SDKkeyword"&gt;Double&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.NaN;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//add the WrapPanel as sole child of Window&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;this&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.Content = dp;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//Add Rectangles&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle rTop = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Rectangle();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rTop.Fill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.CornflowerBlue);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rTop.Stroke = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.CornflowerBlue);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rTop.Height = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;20&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;;&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;dp.Children.Add(rTop);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rTop.SetValue(DockPanel.DockProperty,Dock.Top);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle rFill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Rectangle();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rFill.Fill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.Orange);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;rFill.Stroke = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.Orange);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;dp.Children.Add(rFill);&lt;/span&gt;&lt;/pre&gt;And that's about all there is to basic &lt;code&gt;DockPanel&lt;/code&gt; layout.&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Grid&lt;/h2&gt;  &lt;p&gt;The &lt;code&gt;Grid&lt;/code&gt; control, is by far, the most sophisticated WPF layout control there is (at present). It is sort of like an HTML table control, where you can specify rows and columns, and have cells that span multiple rows, or cells that span multiple columns. There is also a strange syntax which may be used for the Width/Height of Columns and Rows, which is known as the Star "*" notation, which is exposed through the use of the &lt;code&gt;GridLength&lt;/code&gt; class. Think of this as being like a percentage of what's left divider. For example I could have some markup such as:&lt;br /&gt;&lt;/p&gt;&lt;pre style="margin-top: 0pt; color: rgb(153, 0, 0);" id="pre12" lang="xml"&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;40"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;*"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;2*"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;Where I have declared three &lt;code&gt;Grid ColumnDefinition&lt;/code&gt; controls, where the first &lt;code&gt;ColumnDefinition&lt;/code&gt; gets a fixed width of 40 pixels, and the remaining space is divided between the last two &lt;code&gt;ColumnDefinition&lt;/code&gt; controls, where the last one gets twice as much as the second last one. This is the same principle for &lt;code&gt;RowDefinition&lt;/code&gt;. &lt;/p&gt;  &lt;p&gt;In order for child controls of a &lt;code&gt;Grid&lt;/code&gt; control to tell the WPF layout system which cell they belong to, we simply use the following dependency/attached properties, which use a 0 based index. &lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;code&gt;Grid.Column&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;Grid.Row&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;And to specify how many rows or columns a cell should occupy, we simply use the following dependency/attached properties, which starts at &lt;code&gt;&lt;span class="code-digit"&gt;1&lt;/span&gt;&lt;/code&gt;. &lt;/p&gt;  &lt;ul&gt;&lt;li&gt;&lt;code&gt;Grid.ColumnSpan&lt;/code&gt; &lt;/li&gt;&lt;li&gt;&lt;code&gt;Grid.RowSpan&lt;/code&gt; &lt;/li&gt;&lt;/ul&gt;  &lt;p&gt;By clever usage of a &lt;code&gt;Grid&lt;/code&gt; control, you should almost be able to mimic any of the other layout controls. I'll leave that as an exercise for the reader. &lt;/p&gt;  Let's see an example of the &lt;code&gt;Grid&lt;/code&gt; control, shall we? The following picture shows a &lt;code&gt;Grid&lt;/code&gt; control with 3 Columns and 1 Row, where there are two children. The first child occupies Column 1, and the second child occupies Columns 2-3 as its &lt;code&gt;Grid.ColumnSpan&lt;/code&gt; is set to 2.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_izSprwkJon8/SleElL9TlvI/AAAAAAAAADU/oeimkD48T3c/s1600-h/GridDEMO.png"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 238px;" src="http://1.bp.blogspot.com/_izSprwkJon8/SleElL9TlvI/AAAAAAAAADU/oeimkD48T3c/s320/GridDEMO.png" alt="" id="BLOGGER_PHOTO_ID_5356896056180446962" border="0" /&gt;&lt;/a&gt;So how does this look in code? Well in XAML, it is as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre style="margin-top: 0pt; color: rgb(153, 0, 0);" id="pre13" lang="xml"&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;xmlns&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://schemas.microsoft.com/winfx/2006/xaml/presentation"&lt;/span&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;xmlns:x&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;http://schemas.microsoft.com/winfx/2006/xaml"&lt;/span&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;x:Class&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;WPF_Tour_Beginners_Layout.GridDEMO"&lt;/span&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;x:Name&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Window"&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;Title&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;GridDEMO"&lt;/span&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;WindowStartupLocation&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;CenterScreen"&lt;/span&gt;&lt;br /&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;640"&lt;/span&gt; &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;480"&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Grid&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Auto"&lt;/span&gt; &lt;span class="code-attribute"&gt;Height&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Auto"&lt;/span&gt; &lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;         &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;40"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;         &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;*"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;         &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;ColumnDefinition&lt;/span&gt; &lt;span class="code-attribute"&gt;Width&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;2*"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Grid.ColumnDefinitions&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Rectangle&lt;/span&gt; &lt;span class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Aqua"&lt;/span&gt; &lt;span class="code-attribute"&gt;Grid.Column&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;0"&lt;/span&gt; &lt;span class="code-attribute"&gt;Grid.Row&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;0"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;     &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Rectangle&lt;/span&gt; &lt;span class="code-attribute"&gt;Fill&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;Plum"&lt;/span&gt; &lt;span class="code-attribute"&gt;Grid.Column&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;1"&lt;/span&gt; &lt;span class="code-attribute"&gt;Grid.ColumnSpan&lt;/span&gt;&lt;span class="code-keyword"&gt;="&lt;/span&gt;&lt;span class="code-keyword"&gt;2"&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt; &lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Grid&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="code-keyword"&gt;&lt;&lt;/span&gt;&lt;span class="code-keyword"&gt;/&lt;/span&gt;&lt;span class="code-leadattribute"&gt;Window&lt;/span&gt;&lt;span class="code-keyword"&gt;&gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;And in C#, this would be as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre style="margin-top: 0pt;" id="pre14" lang="cs"&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Grid grid = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Grid();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.Width = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-SDKkeyword"&gt;Double&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.NaN;    &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//this is the same as Width="Auto" in XAML&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.Height = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-SDKkeyword"&gt;Double&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.NaN;   &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//this is the same as Height="Auto" in XAML&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//add the Grid as sole child of Window&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;this&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;.Content = grid;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//col1&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;ColumnDefinition cd1 = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; ColumnDefinition();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;cd1.Width = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; GridLength(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;40&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.ColumnDefinitions.Add(cd1);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//col2&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;ColumnDefinition cd2 = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; ColumnDefinition();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;cd2.Width = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; GridLength(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;1&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, GridUnitType.Star);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.ColumnDefinitions.Add(cd2);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//col3&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;ColumnDefinition cd3 = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; ColumnDefinition();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;cd3.Width = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; GridLength(&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;, GridUnitType.Star);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.ColumnDefinitions.Add(cd3);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-comment"&gt;//Now add the cells to the grid&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle r1c1 = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Rectangle();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r1c1.Fill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.Aqua);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r1c1.SetValue(Grid.ColumnProperty, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r1c1.SetValue(Grid.RowProperty, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;0&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.Children.Add(r1c1);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;Rectangle r1c23 = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; Rectangle();&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r1c23.Fill = &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-keyword"&gt;new&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt; SolidColorBrush(Colors.Plum);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r1c23.SetValue(Grid.ColumnProperty, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;1&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;r1c23.SetValue(Grid.ColumnSpanProperty, &lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);" class="code-digit"&gt;2&lt;/span&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;);&lt;/span&gt;&lt;br /&gt;&lt;span style="color: rgb(51, 51, 255);"&gt;grid.Children.Add(r1c23);&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;As I say, the &lt;code&gt;Grid&lt;/code&gt; control is quite sophisticated so I urge you to explore&lt;br /&gt;this one further. You can do all sorts of things with the &lt;code&gt;Grid&lt;/code&gt; such as have&lt;br /&gt;&lt;strong&gt;&lt;code&gt;GridSplitter&lt;/code&gt; controls for resizing Columns/Rows, and you can set up shared&lt;br /&gt;sizes across multiple grids, this is known as &lt;code&gt;SizeGroup&lt;/code&gt;. So please explore the&lt;br /&gt;&lt;code&gt;Grid&lt;/code&gt; control further&lt;/strong&gt;.&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-1501705244347377919?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/1501705244347377919/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/07/wpf-beginners-tutorial-part-1.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/1501705244347377919'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/1501705244347377919'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/07/wpf-beginners-tutorial-part-1.html' title='WPF - Beginners tutorial PART - 1'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://4.bp.blogspot.com/_izSprwkJon8/SleCA8LTbVI/AAAAAAAAADE/Ve5Zc20DBuc/s72-c/WrapPanelDEMO.png' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-7778185905266855081</id><published>2009-04-21T12:07:00.002+05:30</published><updated>2009-04-21T12:30:39.895+05:30</updated><title type='text'>Free Cool ListBox - Customized for alternate item colors and text wrap properties.</title><content type='html'>I have got a requirement to design a list box with alternate items coloring and text wrapping feature. I have tried for one in the google but very less help could be found. &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;So I designed one cool listbox that with the above requirements satisfied. I have given the code below. &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;My List box looks like the below image..&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_izSprwkJon8/Se1uzZkW1aI/AAAAAAAAAC8/0hvbWxETURk/s1600-h/CoolListBox.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 235px;" src="http://3.bp.blogspot.com/_izSprwkJon8/Se1uzZkW1aI/AAAAAAAAAC8/0hvbWxETURk/s320/CoolListBox.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5327035763564926370" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;To acheive this, First you have to add one ListBox control and one Textbox with multiline property enabled underneath it. I have named my textbox as txtMessage and ListBox as ListBox1. &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;The below code shows how to add the contents from the text box on carriage return press ('Enter' button press)...&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; txtMessage_KeyPress(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, KeyPressEventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (e.KeyChar == 13)&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;                ListBox1.Items.Add(txtMessage.Text.Trim().ToString());&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                txtMessage.Text = &lt;span class="str"&gt;""&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Now, folllow the instructions below...&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;1.Select the ListBox1 from your design view and make the &lt;b&gt;"DrawMode" property as "OwnerDrawVariable"&lt;/b&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;2. Generate the event for DrawItem and MeasureItem of the ListBox.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;  &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="rem"&gt;/// DrawItem event triggers when the list box is visible in the form&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ListBox1_DrawItem(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, DrawItemEventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (ListBox1.Items.Count &amp;gt; 0)&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;                &lt;span class="rem"&gt;// Draw the background of the ListBox control for each item.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;                &lt;span class="rem"&gt;// Create a new Brush and initialize to a Black colored brush&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                &lt;span class="rem"&gt;// by default. And inintialise other properties to set the font &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                &lt;span class="rem"&gt;//bg color font size etc.. as below.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;                FontFamily family = FontFamily.GenericSerif;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;                &lt;span class="kwrd"&gt;float&lt;/span&gt; size = 8F;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;                Font myFont = &lt;span class="kwrd"&gt;new&lt;/span&gt; Font(family, size, FontStyle.Regular);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;                Color highlightercolor = Color.White;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;                Brush fontcolor = Brushes.Black;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;                &lt;span class="rem"&gt;//Method call to draw the back ground if the list box [Metadata]&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;                e.DrawBackground();&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;                &lt;span class="rem"&gt;//Inintialize a rectangle to contain each item&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;                Rectangle rectangle = &lt;span class="kwrd"&gt;new&lt;/span&gt; Rectangle(2, e.Bounds.Top + 2,&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;                            e.Bounds.Height, e.Bounds.Height - 4);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;                &lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;                &lt;span class="rem"&gt;//Select alternate items &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;                &lt;span class="kwrd"&gt;int&lt;/span&gt; type = 0;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;                type = e.Index % 2;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;                &lt;span class="rem"&gt;// Determine the color of the font, bg color, and brush to &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;                &lt;span class="rem"&gt;//draw each item based on the index of the item to draw.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;                &lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;                &lt;span class="kwrd"&gt;switch&lt;/span&gt; (type)&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;                {&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;case&lt;/span&gt; 0:&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;                        family = FontFamily.GenericSansSerif;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;                        size = 8;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;                        myFont = &lt;span class="kwrd"&gt;new&lt;/span&gt; Font(family, size, FontStyle.Regular);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;                        highlightercolor = Color.Gainsboro;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;                        fontcolor = Brushes.Black;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;                        &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;case&lt;/span&gt; 1:&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;                        family = FontFamily.GenericSansSerif;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;                        size = 8;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;                        myFont = &lt;span class="kwrd"&gt;new&lt;/span&gt; Font(family, size, FontStyle.Regular);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;                        highlightercolor = Color.WhiteSmoke;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;                        fontcolor = Brushes.Black;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;                        &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;                    &lt;span class="kwrd"&gt;default&lt;/span&gt;:&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt;                        &lt;span class="kwrd"&gt;break&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt;                }&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;                &lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt;                &lt;span class="rem"&gt;// Draw the current item text based on the current &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;                &lt;span class="rem"&gt;// Font and the custom brush settings.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;                e.Graphics.FillRectangle(&lt;span class="kwrd"&gt;new&lt;/span&gt; SolidBrush(highlightercolor), e.Bounds);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt;                &lt;span class="rem"&gt;// Draw each string in the Listbox, &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;                e.Graphics.DrawString(((ListBox)sender).Items[e.Index].ToString(), &lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt;                    myFont, fontcolor, &lt;span class="kwrd"&gt;new&lt;/span&gt; RectangleF(e.Bounds.X + rectangle.Width, &lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt;                        e.Bounds.Y, e.Bounds.Width, e.Bounds.Height));&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;                &lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;                &lt;span class="rem"&gt;// If the ListBox has focus, draw a focus rectangle &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  68:  &lt;/span&gt;                &lt;span class="rem"&gt;// around the selected item.&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  69:  &lt;/span&gt;               &lt;span class="rem"&gt;// [Metadata]&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  70:  &lt;/span&gt;                e.DrawFocusRectangle();&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  71:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  72:  &lt;/span&gt;&amp;nbsp;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  73:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;The above method takes care on the alternate back ground color, font properties etc..&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="rem"&gt;/// Event triggers when the ListBox1 is visible in the form&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ListBox1_MeasureItem(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, MeasureItemEventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            Graphics gr = e.Graphics;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            &lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;span class="rem"&gt;//We will get the size of the string which we are about to draw,&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;span class="rem"&gt;//so that we could set the ItemHeight and ItemWidth property &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            SizeF size = gr.MeasureString(((ListBox)sender).Items[e.Index].ToString(), &lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;                ((ListBox)sender).Font,&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                ((ListBox)sender).Width - 3 - SystemInformation.VerticalScrollBarWidth);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            &lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            &lt;span class="rem"&gt;//Set the height and width to the item&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            e.ItemHeight = Convert.ToInt16(size.Height) + 5;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;            e.ItemWidth = Convert.ToInt16(size.Width) + 3;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;This above method declares the wrap of the content of the ListBox1.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;You can alter the features as you like, hopefully all the code were explained neatly.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-7778185905266855081?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/7778185905266855081/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/free-cool-listbox-customized-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/7778185905266855081'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/7778185905266855081'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/free-cool-listbox-customized-for.html' title='Free Cool ListBox - Customized for alternate item colors and text wrap properties.'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_izSprwkJon8/Se1uzZkW1aI/AAAAAAAAAC8/0hvbWxETURk/s72-c/CoolListBox.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-8298222863533992858</id><published>2009-04-20T22:27:00.003+05:30</published><updated>2009-04-20T22:56:23.046+05:30</updated><title type='text'>Marquee in Windows forms</title><content type='html'>There are scenarios where we need to use marquees in windows applications. But there are no controls introduced for this in .NET frameworks until 3.5 SP1. &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;I have tried some marquee controls available ready in google search and code project, but they are not thead safe in my experience i faced problems in using them in my project as it is.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt; Here I have given a simple code to create your own marquee that is thread safe and reasonably serves your requirement with out causing any problem.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;System.Text.StringBuilder sb;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="rem"&gt;/// Method called during form load. initiates MArquee items&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="kwrd"&gt;void&lt;/span&gt; StartMarquee()&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;            &lt;span class="rem"&gt;//This method sets all the input for your marquee&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            sb = &lt;span class="kwrd"&gt;new&lt;/span&gt; System.Text.StringBuilder(Marquee.marqueeProperties.Text + &lt;span class="str"&gt;" -- "&lt;/span&gt;);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            &lt;span class="rem"&gt;//Enable the timer control &lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            timerMarquee.Enabled = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            &lt;span class="rem"&gt;//You can simply alter the speed of the marquee&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            timerMarquee.Interval = Marquee.marqueeProperties.RotationSpeed;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;            &lt;span class="rem"&gt;//Change the marquee text color&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;            txtMarqueeDisplay.ForeColor = Marquee.marqueeProperties.TextColor;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            &lt;span class="rem"&gt;//Change the bach ground color here&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            txtMarqueeDisplay.BackColor = Marquee.marqueeProperties.TextBgColor;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;The above has to be called from your windows form load where you have to have your text box control where the marquee is going to be displayed. Here my text box is named as "txtMarqueeDisplay".&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;  &lt;span class="rem"&gt;/// &amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        &lt;span class="rem"&gt;/// That Runs Marquee&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="sender"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        &lt;span class="rem"&gt;/// &amp;lt;param name="e"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; timerMarquee_Tick(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;            &lt;span class="rem"&gt;//This is the timer's tick event&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            &lt;span class="kwrd"&gt;char&lt;/span&gt; ch = sb[0];&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            sb.Remove(0, 1);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            sb.Insert(sb.Length, ch);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;            &lt;span class="rem"&gt;//Change the 100 below to fit your requirement&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;            &lt;span class="kwrd"&gt;if&lt;/span&gt; (txtMarqueeDisplay.Text.Length &amp;gt; 100)&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;                txtMarqueeDisplay.Clear();&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            txtMarqueeDisplay.AppendText(sb.ToString());&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;The above method the event from the timer control which is availbale from .NET 2.0&lt;br /&gt;the timer is used to make sure the marque is thread safe!&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Hope you got the marquee in a very simple way!!&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-8298222863533992858?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/8298222863533992858/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/marquee-in-windows-forms.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/8298222863533992858'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/8298222863533992858'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/marquee-in-windows-forms.html' title='Marquee in Windows forms'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-4586050749331988617</id><published>2009-04-19T16:58:00.003+05:30</published><updated>2009-04-19T17:06:52.653+05:30</updated><title type='text'>The Current identity (NTAUTHORITY\NETWORKSERVICE) does not have unit access</title><content type='html'>This error "The Current identity (NTAUTHORITY\NETWORKSERVICE) does not have unit access to 'C:\Windows\Microsoft.Net\Framework\v2.0.50727\Temporary ASP.NET Files'" is caused due to incorrect configuration of IIS for ASP.NET framework 2.0 and above.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;To solve this, we can easily override the faulty settings and re configure the IIS using the following steps...&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;1. Click start and run the command 'cmd'.&lt;br/&gt;&lt;br /&gt;2. Go to the folder "C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727&gt;".&lt;br/&gt;&lt;br /&gt;3. Run the command "aspnet_regiis -i".&lt;br/&gt;&lt;br /&gt;4. This installs the required files and configure the web service extensions too.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_izSprwkJon8/SesMUQfvtaI/AAAAAAAAACs/Ob8LWCZfKPM/s1600-h/regiis_Finished.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 137px;" src="http://2.bp.blogspot.com/_izSprwkJon8/SesMUQfvtaI/AAAAAAAAACs/Ob8LWCZfKPM/s320/regiis_Finished.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5326364526460777890" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;By running the command "aspnet_regiis -i", you install this version of ASP.NET and update script maps at the IIS metabase root and for all scriptmaps below the root. Existing scriptmaps of lower version can be updated to this version.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Also note that, the webservice Extensions has permission 'Allowed' to the 'ASP.NET'. Make sure, you have given the Allowed permission as shown and highlighted in the image.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_izSprwkJon8/SesMoo0xwmI/AAAAAAAAAC0/5G92-iIOIE8/s1600-h/WebServiceExtention.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 225px;" src="http://1.bp.blogspot.com/_izSprwkJon8/SesMoo0xwmI/AAAAAAAAAC0/5G92-iIOIE8/s320/WebServiceExtention.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5326364876588827234" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Hope this helps.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Good Luck!!&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-4586050749331988617?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/4586050749331988617/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/current-identity-ntauthoritynetworkserv.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/4586050749331988617'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/4586050749331988617'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/current-identity-ntauthoritynetworkserv.html' title='The Current identity (NTAUTHORITY\NETWORKSERVICE) does not have unit access'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://2.bp.blogspot.com/_izSprwkJon8/SesMUQfvtaI/AAAAAAAAACs/Ob8LWCZfKPM/s72-c/regiis_Finished.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-6346686444294645743</id><published>2009-04-19T15:30:00.006+05:30</published><updated>2009-04-19T16:57:07.607+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><title type='text'>The page cannot be displayed 404. File or directory not found.</title><content type='html'>Though you have installed IIS and copied your web application in to the root of Websites in a virtual directory folder, you may receive this error.&lt;br/&gt; This problem occurs when you start running your 'ASP.NET' web application probably the first time. Or you have installed .NET Framework latest version and trying to host that application in the IIS.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;It's time you have to register your iis for running this current version of .NET application.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;It's done by using the following simple steps..&lt;br/&gt;&lt;br /&gt;1. Click start and run the command 'cmd'.&lt;br/&gt;&lt;br /&gt;2. Go to the folder "C:\WINDOWS\Microsoft.Net\Framework\v2.0.50727&gt;"&lt;br/&gt;&lt;br /&gt;3. Run the command "aspnet_regiis -i"&lt;br/&gt;&lt;br /&gt;4. This installs the required files and configure the web service extensions too.&lt;br/&gt;&lt;br /&gt;&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_izSprwkJon8/Ser8bgsCPCI/AAAAAAAAACc/7ezzirFEMCE/s1600-h/regiis_Finished.JPG"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 320px; height: 137px;" src="http://1.bp.blogspot.com/_izSprwkJon8/Ser8bgsCPCI/AAAAAAAAACc/7ezzirFEMCE/s320/regiis_Finished.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5326347058880330786" /&gt;&lt;/a&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;By running the command "aspnet_regiis -i", you install this version of ASP.NET and update script maps at the IIS metabase root and for all scriptmaps below the root. Existing scriptmaps of lower version can be updated to this version. &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Also note that, the webservice Extensions has permission 'Allowed' to the 'ASP.NET'. &lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_izSprwkJon8/SesJ7Yj0ubI/AAAAAAAAACk/4FECZ7oMPJo/s1600-h/WebServiceExtention.JPG"&gt;&lt;img style="float:left; margin:0 10px 10px 0;cursor:pointer; cursor:hand;width: 320px; height: 225px;" src="http://3.bp.blogspot.com/_izSprwkJon8/SesJ7Yj0ubI/AAAAAAAAACk/4FECZ7oMPJo/s320/WebServiceExtention.JPG" border="0" alt=""id="BLOGGER_PHOTO_ID_5326361900105382322" /&gt;&lt;/a&gt;&lt;br /&gt;Make sure, you have given the Allowed permission as shown and highlighted in the image.&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Hope this post helps you to solve the problem. Please feel free to write to me if you still have problem.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Good Luck!!&lt;br/&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-6346686444294645743?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/6346686444294645743/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/page-cannot-be-displayed-404-file-or.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/6346686444294645743'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/6346686444294645743'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/page-cannot-be-displayed-404-file-or.html' title='The page cannot be displayed 404. File or directory not found.'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_izSprwkJon8/Ser8bgsCPCI/AAAAAAAAACc/7ezzirFEMCE/s72-c/regiis_Finished.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-5252363310743778535</id><published>2009-04-18T15:24:00.005+05:30</published><updated>2009-04-18T15:42:09.009+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><title type='text'>Server Application Unavailable - IIS Error</title><content type='html'>When you try to host your web application and browse, the error "Server application Unavailable" may raise to surprise you.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;If you are a victim of this problem, pls read further, its far easy to solve.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Please follow the below steps... &lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;1. Go to your web applications Virtual directory in your website root.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;2. Right click and go to 'Permissions' .&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;3. Under the tab 'Security' you will find a 'Group of users list'.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;4. Try to find out 'User_&lt;your computer="" name=""&gt;'.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;5. If it is not there, click ADD button as shown in the image below.&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_izSprwkJon8/SemmqsWfEEI/AAAAAAAAACU/urYlj5YR_qw/s1600-h/Permissions.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 263px; height: 320px;" src="http://1.bp.blogspot.com/_izSprwkJon8/SemmqsWfEEI/AAAAAAAAACU/urYlj5YR_qw/s320/Permissions.JPG" alt="" id="BLOGGER_PHOTO_ID_5325971286732509250" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;6. In the popup that arrives, click Advanced, and find now.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;7. You will be seeing a lis t of users under Name column.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;8. Find Users name of your computer and ADD.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;9. So that you can see that name in the security tab.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;10. Now refresh and try again.&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;You are most probably done. If you have any issues pls feel free to write to me in the comments.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Good Luck!!&lt;br /&gt;&lt;/your&gt;&lt;/span&gt;&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-5252363310743778535?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/5252363310743778535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/server-application-unavailable-iis.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/5252363310743778535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/5252363310743778535'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/server-application-unavailable-iis.html' title='Server Application Unavailable - IIS Error'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_izSprwkJon8/SemmqsWfEEI/AAAAAAAAACU/urYlj5YR_qw/s72-c/Permissions.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-8516418312373195843</id><published>2009-04-18T14:43:00.008+05:30</published><updated>2009-04-18T15:19:57.051+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><title type='text'>It is an error to use a section registered as allow defenition='Machine To Application' beyond application level.</title><content type='html'>This error can be caused by a virtual directory not being configured as an application in IIS.&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This error may look strange but the solution is simple. If you manually copy a ASP.NET application as virtual directory. This error may occur due to the application is not configured with an application name.&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;See the image below..&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_izSprwkJon8/SemcwCpJMKI/AAAAAAAAACM/Q47GeTLMKhQ/s1600-h/ApplicationNameCreate.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 309px;" src="http://1.bp.blogspot.com/_izSprwkJon8/SemcwCpJMKI/AAAAAAAAACM/Q47GeTLMKhQ/s320/ApplicationNameCreate.JPG" alt="" id="BLOGGER_PHOTO_ID_5325960383499415714" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;Follow the below steps...&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;1. Open the Virtual Directory's properties you will get the popup as seen in the image.&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;2. Under Application Settings Click the "Create" button. You will now automatically get a application name.&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="color: rgb(0, 0, 153);"&gt;3.Save the settings and try again.&lt;br/&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;This will hopefully works.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Good Luck!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-8516418312373195843?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/8516418312373195843/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/it-is-error-to-use-section-registered.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/8516418312373195843'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/8516418312373195843'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/it-is-error-to-use-section-registered.html' title='It is an error to use a section registered as allow defenition=&apos;Machine To Application&apos; beyond application level.'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_izSprwkJon8/SemcwCpJMKI/AAAAAAAAACM/Q47GeTLMKhQ/s72-c/ApplicationNameCreate.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-5768136467923360864</id><published>2009-04-18T14:14:00.008+05:30</published><updated>2009-04-18T14:41:07.817+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='IIS'/><title type='text'>Page Cannot be displayed HTTP Error 403.1 Forbidden; Execute access is denied.</title><content type='html'>This is one of the common errors when working with IIS for hosting ASP.NET web applications.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;The cause for this error in many cases is due to unmatched Execute Permission.&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;To solve this follow the steps below...&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;1. Go to IIS and select your web application's virtual directory.&lt;br/&gt;&lt;br /&gt;2. Right click and select properties.&lt;br/&gt;&lt;br /&gt;3. On the popup select the virtual directory tab.&lt;br/&gt;&lt;br /&gt;4.Under Application Settings find 'Execute Permissions'.&lt;br/&gt;&lt;br /&gt;5. In the drop down select Scripts only if your are going to run any scripts in your application and so for any executable.&lt;br/&gt;&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_izSprwkJon8/SemWuvBdH2I/AAAAAAAAACE/mHNIdKKcZaM/s1600-h/Execute+Permission.JPG"&gt;&lt;img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 320px; height: 309px;" src="http://3.bp.blogspot.com/_izSprwkJon8/SemWuvBdH2I/AAAAAAAAACE/mHNIdKKcZaM/s320/Execute+Permission.JPG" alt="" id="BLOGGER_PHOTO_ID_5325953763983040354" border="0" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br/&gt;&lt;br /&gt;In my case, i selected 'Scripts Only'.&lt;br /&gt;&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Hope you got the solution.&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Good Luck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-5768136467923360864?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/5768136467923360864/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/page-cannot-be-displayed-http-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/5768136467923360864'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/5768136467923360864'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/page-cannot-be-displayed-http-error.html' title='Page Cannot be displayed HTTP Error 403.1 Forbidden; Execute access is denied.'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://3.bp.blogspot.com/_izSprwkJon8/SemWuvBdH2I/AAAAAAAAACE/mHNIdKKcZaM/s72-c/Execute+Permission.JPG' height='72' width='72'/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8499391930434267990.post-3395605726729079990</id><published>2009-04-11T10:36:00.006+05:30</published><updated>2009-04-18T15:23:34.497+05:30</updated><category scheme='http://www.blogger.com/atom/ns#' term='C# Classes'/><title type='text'>Input String was not in correct format; String to Int32 Conversion Problem.</title><content type='html'>There is a strange behavior of the Convert Class, when converting a string of value 0 as decimal "0.0" using the code..&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; button1_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; Result = 0;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                &lt;span class="kwrd"&gt;string&lt;/span&gt; inputString = textBox1.Text;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                Result = Int32.Parse(inputString);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                label3.Text = Result.ToString();&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception Ex)&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                MessageBox.Show(Ex.Message);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;Where the textbox value is "0.0". It returns the Exception "Input string was not in correct format". For all other values it returns the equivalent Integer value including '0'.&lt;br /&gt;&lt;br /&gt;How to Solve this problem?&lt;br /&gt;&lt;br /&gt;Use the below code..&lt;br /&gt;&lt;br /&gt;&lt;!-- code formatted by http://manoli.net/csharpformat/ --&gt;&lt;br /&gt;&lt;style type="text/css"&gt;&lt;br /&gt;.csharpcode, .csharpcode pre&lt;br /&gt;{&lt;br /&gt; font-size: small;&lt;br /&gt; color: black;&lt;br /&gt; font-family: Consolas, "Courier New", Courier, Monospace;&lt;br /&gt; background-color: #ffffff;&lt;br /&gt; /*white-space: pre;*/&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode pre { margin: 0em; }&lt;br /&gt;&lt;br /&gt;.csharpcode .rem { color: #008000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .kwrd { color: #0000ff; }&lt;br /&gt;&lt;br /&gt;.csharpcode .str { color: #006080; }&lt;br /&gt;&lt;br /&gt;.csharpcode .op { color: #0000c0; }&lt;br /&gt;&lt;br /&gt;.csharpcode .preproc { color: #cc6633; }&lt;br /&gt;&lt;br /&gt;.csharpcode .asp { background-color: #ffff00; }&lt;br /&gt;&lt;br /&gt;.csharpcode .html { color: #800000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .attr { color: #ff0000; }&lt;br /&gt;&lt;br /&gt;.csharpcode .alt &lt;br /&gt;{&lt;br /&gt; background-color: #f4f4f4;&lt;br /&gt; width: 100%;&lt;br /&gt; margin: 0em;&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;.csharpcode .lnum { color: #606060; }&lt;br /&gt;&lt;/style&gt;&lt;br /&gt;&lt;div class="csharpcode"&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt; &lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; button1_Click(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;        {&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;            &lt;span class="kwrd"&gt;int&lt;/span&gt; Result = 0;&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;            &lt;span class="kwrd"&gt;try&lt;/span&gt;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;                &lt;span class="kwrd"&gt;string&lt;/span&gt; inputString = textBox1.Text;&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;                Result = Int32.Parse(inputString,NumberStyles.AllowDecimalPoint);&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;                label3.Text = Result.ToString();&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;            &lt;span class="kwrd"&gt;catch&lt;/span&gt; (Exception Ex)&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;            {&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;                MessageBox.Show(Ex.Message);&lt;/pre&gt;&lt;br /&gt;&lt;pre class="alt"&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;            }&lt;/pre&gt;&lt;br /&gt;&lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        }&lt;/pre&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;here NumberStyles is as Enumerator available in System.Globalization namespace.&lt;br /&gt;&lt;br /&gt;&lt;br/&gt;&lt;span color="#ffeef"&gt;&lt;br /&gt;Caution: Pass only strings with decimal points as argument&lt;br/&gt;&lt;br/&gt;&lt;br /&gt;&lt;br /&gt;Enjoy!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8499391930434267990-3395605726729079990?l=mydotnetexperiences.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://mydotnetexperiences.blogspot.com/feeds/3395605726729079990/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/input-string-was-not-in-correct-format.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/3395605726729079990'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8499391930434267990/posts/default/3395605726729079990'/><link rel='alternate' type='text/html' href='http://mydotnetexperiences.blogspot.com/2009/04/input-string-was-not-in-correct-format.html' title='Input String was not in correct format; String to Int32 Conversion Problem.'/><author><name>inboxofsiva</name><uri>http://www.blogger.com/profile/00036152674136291579</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='24' height='32' src='http://1.bp.blogspot.com/_izSprwkJon8/Sd7vcVS3gJI/AAAAAAAAABk/bWHHF89Coww/S220/DSC_0299.jpg'/></author><thr:total>2</thr:total></entry></feed>
