<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress.com" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>xaml &amp;laquo; WordPress.com Tag Feed</title>
	<link>http://en.wordpress.com/tag/xaml/</link>
	<description>Feed of posts on WordPress.com tagged "xaml"</description>
	<pubDate>Sun, 29 Nov 2009 02:42:57 +0000</pubDate>

	<generator>http://en.wordpress.com/tags/</generator>
	<language>en</language>

<item>
<title><![CDATA[Calculator Demo -- Part 1]]></title>
<link>http://understandingcsharp.wordpress.com/2009/11/28/calculator-demo-part-1/</link>
<pubDate>Sat, 28 Nov 2009 13:52:09 +0000</pubDate>
<dc:creator>jmancine</dc:creator>
<guid>http://understandingcsharp.wordpress.com/2009/11/28/calculator-demo-part-1/</guid>
<description><![CDATA[After reading through a bunch of the .Net Framework Class Library, I noticed they have some samples ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>After reading through a bunch of the .Net Framework Class Library, I noticed they have some samples for download. I really wanted to dive into GUI programming so I checked out the <a href="http://msdn.microsoft.com/en-us/library/ms771362.aspx">Calculator Demo</a>.</p>
<p>I knew it would be fairly complicated from the description but when I opened the source, I was taken aback by the complexity. As the comments pointed out, it wouldn&#8217;t compile correctly in the command line because of &#8220;missing files&#8221; but I still couldn&#8217;t get that to work so I fired up the behemoth Visual Studio and, it&#8217;s true, &#8220;this example doesn&#8217;t build unless&#8230;&#8221;.</p>
<p>The calculator was running, I played around to experience the features, then went back to the source code. From the tutorials I had looked at <a href="http://understandingcsharp.wordpress.com/2009/11/28/initial-resources/">previously</a>, I knew every C# program needed to have a static Main() method as a starting point. I searched every file for &#8220;Main&#8221; but to no avail. I searched the internet for C# applications without Main() but to no avail. </p>
<p>Since the easy path to understanding wasn&#8217;t working out, I stretched my arms and began looking through each source file for the starting point of the application. Eventually, I found <code>Startup="AppStartingUp"</code> in <em>app.xaml</em> which quickly led me to <code>void AppStartingUp(object sender, StartupEventArgs e)</code> in <em>app.xaml.cs</em> (conveniently enough).</p>
<p>This discovery didn&#8217;t help me understand what was happening but it did lead me to search for <a href="http://msdn.microsoft.com/en-us/library/ms747122.aspx">xaml</a> which happens to stand for &#8220;Extensible Application Markup Language&#8221; and, like C# and .NET, was created by Microsoft and looks to be just as complicated.</p>
<p>Of course, since I had never heard of it before, I realized I would need to find a primer on XAML. <a href="http://www.c-sharpcorner.com/Blogs/BlogDetail.aspx?BlogId=143">My First XAML Application</a> is a perfect introduction. As it turns out, the C# language isn&#8217;t too difficult but .NET is a tremendously large framework which is going to force me to learn a lot more than just C#. I mean, XAML is just part of the <a href="http://msdn.microsoft.com/en-us/library/ms754130.aspx">Windows Presentation Foundation</a>!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Silverlight Out of Browser with new WebBrowser]]></title>
<link>http://fragiledevelopment.wordpress.com/2009/11/27/silverlight-out-of-browser-with-new-webbrowser/</link>
<pubDate>Fri, 27 Nov 2009 14:05:12 +0000</pubDate>
<dc:creator>Viktor Larsson</dc:creator>
<guid>http://fragiledevelopment.wordpress.com/2009/11/27/silverlight-out-of-browser-with-new-webbrowser/</guid>
<description><![CDATA[Today I’m making a demo application. It’s a simple PDF reader in Silverlight and it uses two new fea]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Today I’m making a demo application. It’s a simple PDF reader in Silverlight and it uses two new features. The <strong>Silverlight Out Of Browser </strong>(SLOOB) with elevated permissions, and the <strong>WebBrowser Control</strong>. Those of you who’ve written some WPF might already be familiar with the WebBrowser control and what it can do. In Silverlight, it’s basically an html-renderer for when you’re out of browser. </p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/sloob.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="SLOOB" border="0" alt="SLOOB" src="http://fragiledevelopment.files.wordpress.com/2009/11/sloob_thumb.png?w=375&#038;h=173" width="375" height="173" /></a> </p>
<p> <!--more-->
<p>Let’s start by making a new Silverlight application. Create it with a website attached to it. First some basic XAML code to create the WebBrowser control:</p>
<blockquote><p>&#60;Grid x:Name=&#34;LayoutRoot&#34; Background=&#34;White&#34; Margin=&#34;50&#34;&#62;</p>
<p>&#60;Border BorderBrush=&#34;Black&#34; BorderThickness=&#34;10&#34; &#62;     <br />&#160;&#160; &#60;WebBrowser Name=&#34;myBrowser&#34;/&#62;      <br />&#60;/Border&#62;</p>
<p>&#60;/StackPanel&#62;</p>
</blockquote>
<p>I’ve chosen to add a margin and a border for increased visibility and separation. </p>
<p>Try and run this application. You’ll see how the WebBrowser control does nothing while in browser. </p>
<p><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="Capture" border="0" alt="Capture" src="http://fragiledevelopment.files.wordpress.com/2009/11/capture_thumb.jpg?w=280&#038;h=296" width="280" height="296" /></p>
<p>Now go to your Silverlight project file and select Properties. You’re going to allow OOB deployment.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/2.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="2" border="0" alt="2" src="http://fragiledevelopment.files.wordpress.com/2009/11/2_thumb.jpg?w=450&#038;h=353" width="450" height="353" /></a> </p>
<p>Next, restart your application and install it to your desktop.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/3.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="3" border="0" alt="3" src="http://fragiledevelopment.files.wordpress.com/2009/11/3_thumb.png?w=450&#038;h=175" width="450" height="175" /></a> </p>
<p>This next part is important, set your Silverlight project file as your startup and go back into Properties. This time go to the Debug menu and select your OOB program as the default debug target. This way you won’t have to reinstall it every time you’ve made a change.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/4.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="4" border="0" alt="4" src="http://fragiledevelopment.files.wordpress.com/2009/11/4_thumb.jpg?w=450&#038;h=201" width="450" height="201" /></a> </p>
<p>Lastly, simply set myWebbrowser’s source to a pdf file located in your Client Bin. </p>
<blockquote><p>&#60;WebBrowser Name=&#34;myBrowser&#34; Source=&#34;example.pdf&#34;/&#62;</p>
</blockquote>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image11.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="image" border="0" alt="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb9.png?w=176&#038;h=51" width="176" height="51" /></a>     <br />Now relaunch your application and you’ll find you have a fully functional PDF viewer with <strong>separate interaction areas</strong>. This means that the context menu for the PDF viewer is separate from the one in Silverlight. </p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/5.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="5" border="0" alt="5" src="http://fragiledevelopment.files.wordpress.com/2009/11/5_thumb.jpg?w=450&#038;h=355" width="450" height="355" /></a> </p>
<p>Where you go from here is up to you. Good luck!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Use Visual Brush to fill the shape with Controls]]></title>
<link>http://zamjad.wordpress.com/2009/11/26/use-visual-brush-to-fill-the-shape-with-controls/</link>
<pubDate>Fri, 27 Nov 2009 04:54:40 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/26/use-visual-brush-to-fill-the-shape-with-controls/</guid>
<description><![CDATA[We have already discuss the usage of Visual Brush and see how we can use it to make a text reflectio]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We have already discuss the usage of Visual Brush and see how we can use it to make a text reflection. This time we are going to make a visual brush to fill the geometrical shape with control. We will do a binding of Visual Brush with UIElement, just like we use to do data binding with other UIElement. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Ellipse</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 	<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Ellipse.Fill</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">VisualBrush</span> <span style="color:#ff0000;">Visual</span>=<span style="color:#0000ff;">&#34;{Binding ElementName=list}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 	<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Ellipse.Fill</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Ellipse</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: </pre>
</pre>
<p> Here is a class diagram of Brush class. </p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/brush.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="Brush" border="0" alt="Brush" src="http://zamjad.files.wordpress.com/2009/11/brush_thumb.gif?w=652&#038;h=323" width="652" height="323" /></a></p>
<p>Here is a complete program to fill the ellipse with a lix box usingVisual Brush.&#160; </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;VisualBrush.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;Visual Brush&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;400&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;400&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid.RowDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid.RowDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Background</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span> <span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListBox.ItemTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Navy&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListBox.ItemTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Ellipse</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Ellipse.Fill</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">VisualBrush</span> <span style="color:#ff0000;">Visual</span>=<span style="color:#0000ff;">&#34;{Binding ElementName=list}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Ellipse.Fill</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Ellipse</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25: </pre>
</pre>
<p>Here is C# code of this program.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> VisualBrush
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             List&#60;String&#62; stateList = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             stateList.Add(&#34;<span style="color:#8b0000;">Maryland</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             stateList.Add(&#34;<span style="color:#8b0000;">California</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             stateList.Add(&#34;<span style="color:#8b0000;">Virginia</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             stateList.Add(&#34;<span style="color:#8b0000;">Washington</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             stateList.Add(&#34;<span style="color:#8b0000;">New York</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:             stateList.Add(&#34;<span style="color:#8b0000;">Nevada</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             stateList.Add(&#34;<span style="color:#8b0000;">Florida</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:             stateList.Add(&#34;<span style="color:#8b0000;">Arizona</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:             list.ItemsSource = stateList;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41: </pre>
</pre>
<p>This is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/visualbrushoutput.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="VisualBrushOutput" border="0" alt="VisualBrushOutput" src="http://zamjad.files.wordpress.com/2009/11/visualbrushoutput_thumb.gif?w=400&#038;h=400" width="400" height="400" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Data Triggers and Usage in XAML]]></title>
<link>http://codingsense.wordpress.com/2009/11/25/data-triggers-and-usage-in-xaml/</link>
<pubDate>Wed, 25 Nov 2009 05:40:42 +0000</pubDate>
<dc:creator>codingsense</dc:creator>
<guid>http://codingsense.wordpress.com/2009/11/25/data-triggers-and-usage-in-xaml/</guid>
<description><![CDATA[Hi, DataTrigger represents a trigger that applies property values or performs actions when the bound]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><font face="Verdana,Arial,Helvetica,sans-serif" size="2">Hi,</p>
<p>DataTrigger represents a trigger that applies property values or performs actions when the bound data meets a specified condition.</p>
<p>In this sample we will explore how this property can be utilized on how we need it to behave. In this sample I will concentrate on Style Triggers and apply them on the datagrid, in similar fashion it can be applied to any of the container control.</p>
<p>Till now I have been using Data Triggers in many of the places in my project. Combining all the solutions I have made a sample in which i will be describing all the types of usages of Data Triggers. </p>
<p>Let us imagine a collection of Fathers which hold FirstName of fathers. Each father has a kids collection where all his kids names are stored.<br />
The collection are displayed in a datagrid and the rows are displayed using a Listview and a gridview.</font></p>
<pre style="overflow:auto;width:95%;color:#000000;line-height:14px;border:#999999 1px dashed;font-size:15px;padding:5px;">
<font color="#0000FF" size="2">&#60;</font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGrid</font><font color="#FF0000" size="2"> AutoGenerateColumns</font><font color="#0000FF" size="2">="False"</font><font color="#FF0000" size="2"> Margin</font><font color="#0000FF" size="2">="28,39,33,21"</font><font color="#FF0000" size="2"> Name</font><font color="#0000FF" size="2">="dataGrid1"&#62;············
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGrid.RowDetailsTemplate</font><font color="#0000FF" size="2">&#62;················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">DataTemplate</font><font color="#0000FF" size="2">&#62;····················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">ListView</font><font color="#FF0000" size="2"> Name</font><font color="#0000FF" size="2">="Kids"</font><font color="#FF0000" size="2"> ItemsSource</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> Kids</font><font color="#0000FF" size="2">}"&#62;························
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">ListView.View</font><font color="#0000FF" size="2">&#62;····························
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">GridView</font><font color="#0000FF" size="2">&#62;································
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">GridViewColumn </font><font color="#FF0000" size="2"> Header</font><font color="#0000FF" size="2">="Kids"</font><font color="#FF0000" size="2"> DisplayMemberBinding</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> Name</font><font color="#0000FF" size="2">}"/&#62;····························
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">GridView</font><font color="#0000FF" size="2">&#62;························
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">ListView.View</font><font color="#0000FF" size="2">&#62;····················
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">ListView</font><font color="#0000FF" size="2">&#62;················
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">DataTemplate</font><font color="#0000FF" size="2">&#62;············
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGrid.RowDetailsTemplate</font><font color="#0000FF" size="2">&#62;············
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGrid.Columns</font><font color="#0000FF" size="2">&#62;················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGridTextColumn</font><font color="#FF0000" size="2"> Header</font><font color="#0000FF" size="2">="Father Name"</font><font color="#FF0000" size="2"> Binding</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> FirstName</font><font color="#0000FF" size="2">}"/&#62;············
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGrid.Columns</font><font color="#0000FF" size="2">&#62;········
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">my</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">DataGrid</font><font color="#0000FF" size="2">&#62;</font>
</pre>
<p><font face="Verdana,Arial,Helvetica,sans-serif" color="#000000" size="2">Now lets create some scenarios in our project in the format the details are to be displayed<br />
<b>Scenario1:</b> Make the families background red where there are no kids<br />
<b>Scenario 2:</b> Hide the families where the name of the father is less than 8 chars<br />
<b>Scenario 3:</b> Make the font bold where the fathers name is greater than 8 chars and there are 2 kids</p>
<p><b><a href="http://www.box.net/shared/c0gz4hqli6">Download Source Code &#8211; 423Kb</a></b></p>
<p><b>Make the families background red where there are no kids</b><br />
Binding is very flexible in WPF you can easily bind to any of the properties available in the class. Like in this scenario we need to check if the kids count in the family is 0. For this we need to declare a style and bind our RowStyle of the grid to the defined style. Lets work on it.<br />
Lets declare a style and name it as CheckKids and check for the kids.count condition for 0. </font></p>
<pre style="overflow:auto;width:95%;color:#000000;line-height:14px;border:#999999 1px dashed;font-size:15px;padding:5px;">
<font color="#008000" size="2"><!--style to display family in Red where there are no kids-->········</font>
<font color="#0000FF" size="2">&#60;</font><font color="#A31515" size="2">Style</font><font color="#FF0000" size="2"> x</font><font color="#0000FF" size="2">:</font><font color="#FF0000" size="2">Key</font><font color="#0000FF" size="2">="CheckKids"</font><font color="#FF0000" size="2"> TargetType</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">x</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">Type</font><font color="#FF0000" size="2"> my</font><font color="#0000FF" size="2">:</font><font color="#FF0000" size="2">DataGridRow</font><font color="#0000FF" size="2">}"&#62;············
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Style.Triggers</font><font color="#0000FF" size="2">&#62;················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">DataTrigger</font><font color="#FF0000" size="2"> Binding</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> Kids</font><font color="#0000FF" size="2">.</font><font color="#FF0000" size="2">Count</font><font color="#0000FF" size="2">}"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="0"&#62;····················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Setter</font><font color="#FF0000" size="2"> Property</font><font color="#0000FF" size="2">="Background"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="Red"/&#62;················
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">DataTrigger</font><font color="#0000FF" size="2">&#62;············
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">Style.Triggers</font><font color="#0000FF" size="2">&#62;········
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">Style</font><font color="#0000FF" size="2">&#62;</font>
</pre>
<p><font face="Verdana,Arial,Helvetica,sans-serif" color="#000000" size="2">In the collection Mr.Ramiayaa has no kids so background of his row is made red.</p>
<p><a href="http://codingsense.wordpress.com/files/2009/11/nokids3.jpg"><img src="http://codingsense.wordpress.com/files/2009/11/nokids3.jpg" alt="" title="NoKids" width="481" height="198" class="alignnone size-full wp-image-385" /></a></p>
<p><b>Hide the families where the name of the father is less than 8 chars</b><br />
Now comes the challange how will you check fatherName &#60; 8 in XAML. Pretty tricky right. Here is a simple method to be followed. What if we have another property in our class which returns true or false by checking the fathername.length. It will help us to acheive our goal. </p>
<p>Lets Declare a property in Father class and name it as IsLengthLessThanEight, which will return if the father name is less than 8 char or not. It will look like</p>
<pre style="overflow:auto;width:95%;color:#000000;line-height:14px;border:#999999 1px dashed;font-size:15px;padding:5px;">
<font color="#0000FF" size="2">public <font color="#0000FF" size="2">bool</font></font><font size="2"> IsLengthLessThanEight
{</font>
<font color="#0000FF" size="2">get </font><font size="2">{ </font><font color="#0000FF" size="2">return</font><font size="2"> (FirstName.Length &#60; 8); }
}</font>
</pre>
<p>By this we can be very sure that we can write our own properties and bind it to make anything possible.<br />
Now lets declare the style and name it FatherNameLessEightChar and bind it to our declared property IsLengthLessThanEight<br />
and check the desired condition.</p>
<pre style="overflow:auto;width:95%;color:#000000;line-height:14px;border:#999999 1px dashed;font-size:15px;padding:5px;">
<font color="#008000" size="2"><!--Style to make family visibility= hidden where fathers name is less than 8 chars-->········</font>
<font color="#0000FF" size="2">&#60;</font><font color="#A31515" size="2">Style</font><font color="#FF0000" size="2"> x</font><font color="#0000FF" size="2">:</font><font color="#FF0000" size="2">Key</font><font color="#0000FF" size="2">="FatherNameLessEightChar"</font><font color="#FF0000" size="2"> TargetType</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">x</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">Type</font><font color="#FF0000" size="2"> my</font><font color="#0000FF" size="2">:</font><font color="#FF0000" size="2">DataGridRow</font><font color="#0000FF" size="2">}"&#62;············
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Style.Triggers</font><font color="#0000FF" size="2">&#62;················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">DataTrigger</font><font color="#FF0000" size="2"> Binding</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> IsLengthLessThanEight</font><font color="#0000FF" size="2">}"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="True"&#62;····················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Setter</font><font color="#FF0000" size="2"> Property</font><font color="#0000FF" size="2">="Visibility"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="Hidden"/&#62;················
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">DataTrigger</font><font color="#0000FF" size="2">&#62;············
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">Style.Triggers</font><font color="#0000FF" size="2">&#62;········
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">Style</font><font color="#0000FF" size="2">&#62;</font>
</pre>
<p>In the collection we have only one father who has the name less than 8 that is Mr.Rocky that name is to be hidden.</p>
<p><a href="http://codingsense.wordpress.com/files/2009/11/lessthaneightchar1.jpg"><img src="http://codingsense.wordpress.com/files/2009/11/lessthaneightchar1.jpg" alt="" title="LessThanEightChar" width="458" height="209" class="alignnone size-full wp-image-386" /></a></p>
<p><font face="Verdana,Arial,Helvetica,sans-serif" color="#000000" size="2"><br />
<b>Make the font bold where the fathers name is greater than 8 chars and there are 2 kids</b><br />
Here comes the next challange how will we check more than one condition in XAML. Is it possible or should we declare another property and check 2 conditions in our class. For this we have MultiDataTrigger which will help us to check multiple conditions in XAML and set property accordingly. Cool.<br />
Lets declare a style and name it CheckNameAndKidsCount and use the MultiDataTrigger.</p>
<pre style="overflow:auto;width:95%;color:#000000;line-height:14px;border:#999999 1px dashed;font-size:15px;padding:5px;">
<font color="#0000FF" size="2">&#60;</font><font color="#A31515" size="2">Style</font><font color="#FF0000" size="2"> x</font><font color="#0000FF" size="2">:</font><font color="#FF0000" size="2">Key</font><font color="#0000FF" size="2">="CheckNameAndKidsCount"</font><font color="#FF0000" size="2"> TargetType</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">x</font><font color="#0000FF" size="2">:</font><font color="#A31515" size="2">Type</font><font color="#FF0000" size="2"> my</font><font color="#0000FF" size="2">:</font><font color="#FF0000" size="2">DataGridRow</font><font color="#0000FF" size="2">}"&#62;············
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Style.Triggers</font><font color="#0000FF" size="2">&#62;················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">MultiDataTrigger</font><font color="#0000FF" size="2">&#62;····················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">MultiDataTrigger.Conditions</font><font color="#0000FF" size="2">&#62;························
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Condition</font><font color="#FF0000" size="2"> Binding</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> IsLengthLessThanEight</font><font color="#0000FF" size="2">}"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="False"/&#62;························
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Condition</font><font color="#FF0000" size="2"> Binding</font><font color="#0000FF" size="2">="{</font><font color="#A31515" size="2">Binding</font><font color="#FF0000" size="2"> Kids</font><font color="#0000FF" size="2">.</font><font color="#FF0000" size="2">Count</font><font color="#0000FF" size="2">}"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="2"/&#62;····················
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">MultiDataTrigger.Conditions</font><font color="#0000FF" size="2">&#62;····················
<font color="#0000FF" size="2">&#60;</font></font><font color="#A31515" size="2">Setter</font><font color="#FF0000" size="2"> Property</font><font color="#0000FF" size="2">="FontWeight"</font><font color="#FF0000" size="2"> Value</font><font color="#0000FF" size="2">="Bold"/&#62;················
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">MultiDataTrigger</font><font color="#0000FF" size="2">&#62;············
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">Style.Triggers</font><font color="#0000FF" size="2">&#62;········
<font color="#0000FF" size="2">&#60;/</font></font><font color="#A31515" size="2">Style</font><font color="#0000FF" size="2">&#62;</font>
</pre>
<p><font face="Verdana,Arial,Helvetica,sans-serif" color="#000000" size="2"><br />
Here we check both the conditions i.e First we check if father name is greater than 8 char with the help of the IsLengthLessThanEight that we have defined and next condition we check if the kids count is 2 or not. If both the conditions are satisfied then the font of the family is made bold.<br />
In our collection we have Mr.Balasubramanyam whose name is greater than 8 char and has 2 childrens so his row should be made bold.</p>
<p><a href="http://codingsense.wordpress.com/files/2009/11/twokidsandbigname1.jpg"><img src="http://codingsense.wordpress.com/files/2009/11/twokidsandbigname1.jpg" alt="" title="TwoKidsAndBigName" width="475" height="217" class="alignnone size-full wp-image-387" /></a></p>
<p>Wow all the scenarios have completed and we have got the desired output for all of them. Thanks to DataTrigger for simplifying the life. In this similar fashion we can declare style trigger and data trigger to make various styles depending on the data that is bound.</p>
<p><b>References :</b><br />
<a href="http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx">http://msdn.microsoft.com/en-us/library/system.windows.datatrigger.aspx</a></p>
<p>Cheers <img src='http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /><br />
Naveen Prabhu</p>
<p></font></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Depreciation using Declining Balance Method]]></title>
<link>http://zamjad.wordpress.com/2009/11/24/depreciation-using-declining-balance-method/</link>
<pubDate>Wed, 25 Nov 2009 04:45:29 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/24/depreciation-using-declining-balance-method/</guid>
<description><![CDATA[We just saw how to calculate the depreciation using straight line method, now we are going to calcul]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We just saw how to calculate the depreciation using straight line method, now we are going to calculate depreciation using another method, i.e. Decline Balance method. This is also known as double declining balance method. Here are are again going to use progress bar in the list control. </p>
<p>Here is a code to calculate the depreciation using declining balance method.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">int</span> iIndex = 0; iIndex &#60; year; iIndex++)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 	depExpense = bookValue * percentage * 2;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: 	<span style="color:#0000ff;">if</span> (bookValue - depExpense &#60; scrap)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 	{
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: 		depExpense = bookValue - scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: 		bookValue = scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: 	}
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: 	<span style="color:#0000ff;">else</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: 	{
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: 		bookValue -= depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: 	}
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: 	accDepreciation += depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17: 	DepreciationInfo dpInfo = <span style="color:#0000ff;">new</span> DepreciationInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18: 	dpInfo.Year = (iIndex + 1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19: 	dpInfo.Depreciation = depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20: 	dpInfo.AccDepreciation = accDepreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21: 	dpInfo.BookValue = bookValue;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22: 	dpInfo.Percentage = (bookValue * 100) / cost; ;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24: 	depreciation.Add(dpInfo);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26: </pre>
</pre>
<p>Here is a complete XAML code of the project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;Depreciation.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;Depreciation&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;400&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;600&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span> <span style="color:#ff0000;">Background</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid.RowDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;4*&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid.RowDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid.ColumnDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ColumnDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ColumnDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid.ColumnDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span><span style="color:#0000ff;">&#62;</span>Enter Cost of Fixed Asset<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBlock</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;txtCost&#34;</span><span style="color:#0000ff;">&#62;</span><span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span><span style="color:#0000ff;">&#62;</span>Enter life Span<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBlock</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;txtYear&#34;</span><span style="color:#0000ff;">&#62;</span><span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span><span style="color:#0000ff;">&#62;</span>Enter Scrap Value<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBlock</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;txtScrapValue&#34;</span><span style="color:#0000ff;">&#62;</span><span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;3&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">ColumnSpan</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:                                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Year&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Year}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Depreciation&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Depreciation}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Accumulated Depreciation&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=AccDepreciation}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Book Value&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=BookValue}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Percentage&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ProgressBar</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;50&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;20&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Minimum</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Maximum</span>=<span style="color:#0000ff;">&#34;100&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;{Binding Percentage}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;4&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;10&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;75&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;btnCalculate&#34;</span> <span style="color:#ff0000;">Click</span>=<span style="color:#0000ff;">&#34;btnCalculate_Click&#34;</span><span style="color:#0000ff;">&#62;</span>Calculate<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Button</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;4&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;10&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;75&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;btnExit&#34;</span> <span style="color:#ff0000;">Click</span>=<span style="color:#0000ff;">&#34;btnExit_Click&#34;</span><span style="color:#0000ff;">&#62;</span>Exit<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Button</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60: </pre>
</pre>
<p>Here is complete C# code of the project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> Depreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         List&#60;DepreciationInfo&#62; depreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">int</span> year;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">double</span> cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">double</span> scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             depreciation = <span style="color:#0000ff;">new</span> List&#60;DepreciationInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnExit_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:             Close();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnCalculate_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:             depreciation.Clear();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:             year = Convert.ToInt32(txtYear.Text);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:             cost = Convert.ToDouble(txtCost.Text);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:             scrap = Convert.ToDouble(txtScrapValue.Text);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             <span style="color:#0000ff;">if</span> (year &#60;= 0)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:                 MessageBox.Show(&#34;<span style="color:#8b0000;">Number of years can not be zero or negative.</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:                 <span style="color:#0000ff;">return</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:             }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:             <span style="color:#0000ff;">if</span> (cost &#60;= 0 &#124;&#124; scrap &#60;= 0)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:             {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:                 MessageBox.Show(&#34;<span style="color:#8b0000;">Either Cost or Scrap value is not correct.</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:                 <span style="color:#0000ff;">return</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:             }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:             <span style="color:#0000ff;">double</span> percentage = 100 / year;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60:             percentage /= 100;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61:             <span style="color:#0000ff;">double</span> accDepreciation = 0;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62:             <span style="color:#0000ff;">double</span> bookValue = cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63:             <span style="color:#0000ff;">double</span> depExpense = 0;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65:             <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">int</span> iIndex = 0; iIndex &#60; year; iIndex++)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 66:             {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 67:                 depExpense = bookValue * percentage * 2;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 68:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 69:                 <span style="color:#0000ff;">if</span> (bookValue - depExpense &#60; scrap)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 70:                 {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 71:                     depExpense = bookValue - scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 72:                     bookValue = scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 73:                 }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 74:                 <span style="color:#0000ff;">else</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 75:                 {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 76:                     bookValue -= depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 77:                 }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 78:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 79:                 accDepreciation += depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 80:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 81:                 DepreciationInfo dpInfo = <span style="color:#0000ff;">new</span> DepreciationInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 82:                 dpInfo.Year = (iIndex + 1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 83:                 dpInfo.Depreciation = depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 84:                 dpInfo.AccDepreciation = accDepreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 85:                 dpInfo.BookValue = bookValue;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 86:                 dpInfo.Percentage = (bookValue * 100) / cost; ;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 87:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 88:                 depreciation.Add(dpInfo);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 89:             }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 90:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 91:             list.ItemsSource = depreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 92:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 93:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 94:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 95:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> DepreciationInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 96:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 97:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Year
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 98:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 99:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">100:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> Depreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">101:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">102:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">103:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> AccDepreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">104:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">105:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">106:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> BookValue
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">107:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">108:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">109:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> Percentage
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">110:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">111:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">112: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">113: </pre>
</pre>
<p>Here is the output of the program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/depreciationoutput.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="DepreciationOutput" border="0" alt="DepreciationOutput" src="http://zamjad.files.wordpress.com/2009/11/depreciationoutput_thumb.gif?w=600&#038;h=400" width="600" height="400" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Adding right-click functionality in Silverlight 4]]></title>
<link>http://fragiledevelopment.wordpress.com/2009/11/24/adding-a-right-click-menu-in-silverlight-4/</link>
<pubDate>Tue, 24 Nov 2009 17:06:59 +0000</pubDate>
<dc:creator>Viktor Larsson</dc:creator>
<guid>http://fragiledevelopment.wordpress.com/2009/11/24/adding-a-right-click-menu-in-silverlight-4/</guid>
<description><![CDATA[Not having the right mouse button available has been a hassle for both Silverlight and Adobe Flash s]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Not having the right mouse button available has been a hassle for both Silverlight and Adobe Flash since their inception. Flash has had the ability to customize their right-click context menu to some degree but never true right click event handling. With Silverlight 4, Silverlight will have true customizable event handling for the right mouse button. I know this might be a small step for event handling, but it’s a giant leap for rich Internet applications.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/smallstepforeventhandling.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border:0;" title="SmallStepForEventHandling" src="http://fragiledevelopment.files.wordpress.com/2009/11/smallstepforeventhandling_thumb.png?w=255&#038;h=199" border="0" alt="SmallStepForEventHandling" width="255" height="199" /></a></p>
<p>To do this in Silverlight 4, this is the code you’ll need to use:</p>
<p><!--more--></p>
<p>We’re going to add an eventhandler first to out main window and then to a control through XAML.</p>
<blockquote><p><span style="font-size:xx-small;"><span style="color:#008000;">//For a general rightclick menu for your window</span></span></p>
<p><span style="font-size:xx-small;">this.MouseRightButtonDown += new MouseButtonEventHandler(MainPage_MouseRightButtonDown);<br />
this.MouseRightButtonUp += new MouseButtonEventHandler(MainPage_MouseRightButtonUp); </span></p>
<p><span style="font-size:xx-small;">void MainPage_MouseRightButtonDown(object sender, MouseButtonEventArgs e)<br />
{<br />
</span><span style="font-size:xx-small;"><span style="color:#008000;">//This is crucial. If you don&#8217;t add this, the original context menu will always show up on rightclick.</span><span style="font-size:xx-small;"><br />
e.Handled = True;<br />
}</span></span></p>
<p><span style="font-size:xx-small;">void MainPage_MouseRightButtonUp(object sender, MouseButtonEventArgs e)<br />
{<br />
MessageBox.Show(&#8220;Hello, Brave New World!&#8221;);<br />
}</span></p></blockquote>
<p><span style="font-size:xx-small;"><span style="color:#008000;"> </span></span></p>
<p>This can of course be used on different objects with different effects and if we want to add an event handler in XAML instead, this is the code we’ll use within an object (such as a Grid):</p>
<blockquote><p>MouseRightButtonDown=&#8221;MainPage_MouseRightButtonDown&#8221;</p>
<p>MouseRightButtonUp=&#8221;MainPage_MouseRightButtonUp&#8221;</p></blockquote>
<p>The possibilities are many and I’m glad to be using a technology that is constantly improving.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Simple Usage of Data Grid Control in WPF 4]]></title>
<link>http://zamjad.wordpress.com/2009/11/23/simple-usage-of-data-grid-control-in-wpf-4/</link>
<pubDate>Tue, 24 Nov 2009 04:11:17 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/23/simple-usage-of-data-grid-control-in-wpf-4/</guid>
<description><![CDATA[WPF 4.0 introduced lots of new feature and one of them is Data Grid control. Here we are going to st]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>WPF 4.0 introduced lots of new feature and one of them is Data Grid control. Here we are going to study the simple usage of Data grid control. Here is a class diagram of DataGrid.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/datagrid.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="DataGrid" border="0" alt="DataGrid" src="http://zamjad.files.wordpress.com/2009/11/datagrid_thumb.gif?w=153&#038;h=214" width="153" height="214" /></a> </p>
<p>Here is a XAML code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;grid.MainWindow&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:         <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:         <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:         <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;Example of Data Grid&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;300&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataGrid</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;grid&#34;</span> <span style="color:#ff0000;">AlternationCount</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Background</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span> <span style="color:#ff0000;">AlternatingRowBackground</span>=<span style="color:#0000ff;">&#34;LightGreen&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataGrid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: </pre>
</pre>
<p>We just create a list of our user define class and assign it to the grid class. Here is a complete C# code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> grid
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for MainWindow.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> MainWindow : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">private</span> List&#60;Student&#62; student;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:         <span style="color:#0000ff;">public</span> MainWindow()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             student = <span style="color:#0000ff;">new</span> List&#60;Student&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             student.Add(<span style="color:#0000ff;">new</span> Student(10, &#34;<span style="color:#8b0000;">Bob</span>&#34;, &#34;<span style="color:#8b0000;">Smith</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             student.Add(<span style="color:#0000ff;">new</span> Student(25, &#34;<span style="color:#8b0000;">James</span>&#34;, &#34;<span style="color:#8b0000;">Brown</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             student.Add(<span style="color:#0000ff;">new</span> Student(15, &#34;<span style="color:#8b0000;">Joe</span>&#34;, &#34;<span style="color:#8b0000;">Martin</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             student.Add(<span style="color:#0000ff;">new</span> Student(12, &#34;<span style="color:#8b0000;">Dona</span>&#34;, &#34;<span style="color:#8b0000;">Taylor</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:             student.Add(<span style="color:#0000ff;">new</span> Student(18, &#34;<span style="color:#8b0000;">Peter</span>&#34;, &#34;<span style="color:#8b0000;">Brian</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:             grid.ItemsSource = student;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Student
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:         <span style="color:#0000ff;">public</span> Student(<span style="color:#0000ff;">int</span> id, String firstName, String lastName)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:             ID = id;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:             FirstName = firstName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:             LastName = lastName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> ID
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:         <span style="color:#0000ff;">public</span> String FirstName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:         <span style="color:#0000ff;">public</span> String LastName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58: </pre>
</pre>
<p>Here is the output of this project.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/datagridoutput.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="DataGridOutput" border="0" alt="DataGridOutput" src="http://zamjad.files.wordpress.com/2009/11/datagridoutput_thumb.gif?w=300&#038;h=300" width="300" height="300" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using progress bar inside the List view]]></title>
<link>http://zamjad.wordpress.com/2009/11/22/using-progress-bar-inside-the-tree-view/</link>
<pubDate>Mon, 23 Nov 2009 04:47:37 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/22/using-progress-bar-inside-the-tree-view/</guid>
<description><![CDATA[We can easily insert progras bar inside the tree view just like we added check box and combo box. We]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We can easily insert progras bar inside the tree view just like we added check box and combo box. We are again going to use the CellTemplate property of GridViewColumn. We are going to define data template to use the progress bar. </p>
<p>This time we are going to do something useful rather than using some dummy sample. This time we are going to make one simple application to calculate the book value of a fixed assets cost using the straight line method. </p>
<p>Here is a class to store the information about the depreciation. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> DepreciationInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 	<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Year
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 	{ <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 	<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> Depreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: 	{ <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: 	<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> AccDepreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: 	{ <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: 	<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> BookValue
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: 	{ <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: 	<span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> Percentage
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: 	{ <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18: </pre>
</pre>
<p>Calculation of book value using straight line method is very simple. Here is a simple method to calculate the book value.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">double</span> depExpense = depValue / year;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">double</span> accDepreciation = 0;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">double</span> bookValue = cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">int</span> iIndex = 0; iIndex &#60; year; iIndex++)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: 	accDepreciation += depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: 	bookValue -= depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: 	DepreciationInfo dpInfo = <span style="color:#0000ff;">new</span> DepreciationInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: 	dpInfo.Year = (iIndex + 1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: 	dpInfo.Depreciation = depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: 	dpInfo.AccDepreciation = accDepreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: 	dpInfo.BookValue = bookValue;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14: 	dpInfo.Percentage = bookValue * 100 / cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: 	depreciation.Add(dpInfo);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19: </pre>
</pre>
<p>Here is a complete XAML code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;Depreciation.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;Depreciation&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;400&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;600&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span> <span style="color:#ff0000;">Background</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid.RowDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;4*&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">RowDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid.RowDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid.ColumnDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ColumnDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ColumnDefinition</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid.ColumnDefinitions</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span><span style="color:#0000ff;">&#62;</span>Enter Cost of Fixed Asset<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBlock</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;txtCost&#34;</span><span style="color:#0000ff;">&#62;</span><span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span><span style="color:#0000ff;">&#62;</span>Enter life Span<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBlock</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;txtYear&#34;</span><span style="color:#0000ff;">&#62;</span><span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span><span style="color:#0000ff;">&#62;</span>Enter Scrap Value<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBlock</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBox</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">VerticalAlignment</span>=<span style="color:#0000ff;">&#34;Center&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;txtScrapValue&#34;</span><span style="color:#0000ff;">&#62;</span><span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">TextBox</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;3&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">ColumnSpan</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:                                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Year&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Year}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Depreciation&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Depreciation}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Accumulated Depreciation&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=AccDepreciation}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Book Value&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=BookValue}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Percentage&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ProgressBar</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;50&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;20&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Minimum</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Maximum</span>=<span style="color:#0000ff;">&#34;100&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;{Binding Percentage}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;4&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;10&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;75&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;btnCalculate&#34;</span> <span style="color:#ff0000;">Click</span>=<span style="color:#0000ff;">&#34;btnCalculate_Click&#34;</span><span style="color:#0000ff;">&#62;</span>Calculate<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Button</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Button</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Column</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Grid</span>.<span style="color:#ff0000;">Row</span>=<span style="color:#0000ff;">&#34;4&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;10&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;75&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;btnExit&#34;</span> <span style="color:#ff0000;">Click</span>=<span style="color:#0000ff;">&#34;btnExit_Click&#34;</span><span style="color:#0000ff;">&#62;</span>Exit<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Button</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59: </pre>
</pre>
<p>Here is a complete C# code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> Depreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         List&#60;DepreciationInfo&#62; depreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">int</span> year;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">double</span> cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">double</span> scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             depreciation = <span style="color:#0000ff;">new</span> List&#60;DepreciationInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnExit_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:             Close();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:         <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">void</span> btnCalculate_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:             depreciation.Clear();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:             year = Convert.ToInt32(txtYear.Text);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:             cost = Convert.ToDouble(txtCost.Text);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:             scrap = Convert.ToDouble(txtScrapValue.Text);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             <span style="color:#0000ff;">if</span> (year &#60;= 0)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:                 MessageBox.Show(&#34;<span style="color:#8b0000;">Number of years can not be zero or negative.</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:                 <span style="color:#0000ff;">return</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:             }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:             <span style="color:#0000ff;">double</span> depValue = cost - scrap;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:             <span style="color:#0000ff;">if</span> (depValue &#60;= 0)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:             {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:                 MessageBox.Show(&#34;<span style="color:#8b0000;">Either Cost or Scrap value is not correct.</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:                 <span style="color:#0000ff;">return</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:             }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61:             <span style="color:#0000ff;">double</span> depExpense = depValue / year;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62:             <span style="color:#0000ff;">double</span> accDepreciation = 0;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63:             <span style="color:#0000ff;">double</span> bookValue = cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65:             <span style="color:#0000ff;">for</span> (<span style="color:#0000ff;">int</span> iIndex = 0; iIndex &#60; year; iIndex++)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 66:             {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 67:                 accDepreciation += depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 68:                 bookValue -= depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 69:                 DepreciationInfo dpInfo = <span style="color:#0000ff;">new</span> DepreciationInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 70:                 dpInfo.Year = (iIndex + 1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 71:                 dpInfo.Depreciation = depExpense;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 72:                 dpInfo.AccDepreciation = accDepreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 73:                 dpInfo.BookValue = bookValue;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 74:                 dpInfo.Percentage = bookValue * 100 / cost;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 75:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 76:                 depreciation.Add(dpInfo);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 77:             }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 78:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 79:             list.ItemsSource = depreciation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 80:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 81:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 82:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 83:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> DepreciationInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 84:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 85:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">int</span> Year
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 86:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 87:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 88:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> Depreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 89:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 90:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 91:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> AccDepreciation
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 92:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 93:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 94:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> BookValue
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 95:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 96:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 97:         <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">double</span> Percentage
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 98:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 99:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">100: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">101: </pre>
</pre>
<p>Here is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/depreciation.gif"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="Depreciation" border="0" alt="Depreciation" src="http://zamjad.files.wordpress.com/2009/11/depreciation_thumb.gif?w=600&#038;h=400" width="600" height="400" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Display Hierarchical Data in List view  using Nested Controls]]></title>
<link>http://zamjad.wordpress.com/2009/11/20/display-hierarchical-data-in-list-view-using-nested-controls/</link>
<pubDate>Sat, 21 Nov 2009 04:49:18 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/20/display-hierarchical-data-in-list-view-using-nested-controls/</guid>
<description><![CDATA[&#160; If we have a simple grid form of data then we can simply display it in list view. We can even]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>&#160;</p>
<p>If we have a simple grid form of data then we can simply display it in list view. We can even further customize the display of our data by using data template and display in different controls such as check box, text block etc. </p>
<p>If we have hierarchical data, such as the state information and list of big cities in each state then we can display this in the form of nested combo box inside the list view. </p>
<p>First we have to change our data structure. Now our class contains not only simple data, but also list of string to store more than one big cities in each state. Here is our class look like. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> StateInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:         <span style="color:#0000ff;">private</span> List&#60;String&#62; list;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:         <span style="color:#0000ff;">public</span> StateInfo()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:         <span style="color:#0000ff;">public</span> StateInfo(String name, String capital, String nickName, String timeZone, Boolean visited)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:             Name = name;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:             Capital = capital;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:             NickName = nickName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:             TimeZone = timeZone;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:             Visited = visited;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:             list = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:         <span style="color:#0000ff;">public</span> String Name
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         <span style="color:#0000ff;">public</span> String Capital
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:         <span style="color:#0000ff;">public</span> String NickName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:         <span style="color:#0000ff;">public</span> String TimeZone
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:         <span style="color:#0000ff;">public</span> Boolean Visited
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         <span style="color:#0000ff;">public</span> List&#60;String&#62; Cities
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:             <span style="color:#0000ff;">get</span> { <span style="color:#0000ff;">return</span> list; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:             <span style="color:#0000ff;">set</span> { list = <span style="color:#0000ff;">value</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42: </pre>
</pre>
<p>Now we are going to populate some data in this class. In this example we are inserting data by code, but it can be loaded by database, LINQ or any other techniques. Here is an example of inserting data in this data structure.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: List&#60;StateInfo&#62; statesList = <span style="color:#0000ff;">new</span> List&#60;StateInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: StateInfo s1 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: s1.Name = &#34;<span style="color:#8b0000;">Maryland</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: s1.Capital = &#34;<span style="color:#8b0000;">Annapolis</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: s1.NickName = &#34;<span style="color:#8b0000;">Old Line State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: s1.Visited = <span style="color:#0000ff;">true</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: List&#60;String&#62; s1List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: s1List.Add(&#34;<span style="color:#8b0000;">Frederick</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: s1List.Add(&#34;<span style="color:#8b0000;">Baltimore</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: s1List.Add(&#34;<span style="color:#8b0000;">Rockville</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: s1List.Add(&#34;<span style="color:#8b0000;">Hagerstown</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: s1.Cities = s1List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14: statesList.Add(s1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: StateInfo s2 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17: s2.Name = &#34;<span style="color:#8b0000;">California</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18: s2.Capital = &#34;<span style="color:#8b0000;">Sacramento</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19: s2.NickName = &#34;<span style="color:#8b0000;">Golden State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20: s2.Visited = <span style="color:#0000ff;">true</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21: List&#60;String&#62; s2List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22: s2List.Add(&#34;<span style="color:#8b0000;">Los Angeles</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23: s2List.Add(&#34;<span style="color:#8b0000;">San Franscico</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24: s2List.Add(&#34;<span style="color:#8b0000;">San Deiago</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25: s2List.Add(&#34;<span style="color:#8b0000;">San Jose</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26: s2List.Add(&#34;<span style="color:#8b0000;">Fresno</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27: s2List.Add(&#34;<span style="color:#8b0000;">Long Beach</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28: s2.Cities = s2List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29: statesList.Add(s2);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31: StateInfo s3 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32: s3.Name = &#34;<span style="color:#8b0000;">Taxes</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33: s3.Capital = &#34;<span style="color:#8b0000;">Austin</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34: s3.NickName = &#34;<span style="color:#8b0000;">Lone Star State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35: s3.Visited = <span style="color:#0000ff;">true</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36: List&#60;String&#62; s3List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37: s3List.Add(&#34;<span style="color:#8b0000;">Houston</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38: s3List.Add(&#34;<span style="color:#8b0000;">Dallas</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39: s3List.Add(&#34;<span style="color:#8b0000;">San Antonio</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40: s3List.Add(&#34;<span style="color:#8b0000;">El Paso</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41: s3.Cities = s3List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42: statesList.Add(s3);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44: StateInfo s4 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45: s4.Name = &#34;<span style="color:#8b0000;">Ohio</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46: s4.Capital = &#34;<span style="color:#8b0000;">Columbus</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47: s4.NickName = &#34;<span style="color:#8b0000;">Buckeye State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48: s4.Visited = <span style="color:#0000ff;">false</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49: List&#60;String&#62; s4List = <span style="color:#0000ff;">new</span> List&#60;String&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50: s4List.Add(&#34;<span style="color:#8b0000;">Cleveland</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51: s4List.Add(&#34;<span style="color:#8b0000;">Cincinnati</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52: s4.Cities = s4List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53: statesList.Add(s4);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55: StateInfo s5 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56: s5.Name = &#34;<span style="color:#8b0000;">Florida</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57: s5.Capital = &#34;<span style="color:#8b0000;">Tallahassee</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58: s5.NickName = &#34;<span style="color:#8b0000;">Sunshine State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59: s5.Visited = <span style="color:#0000ff;">false</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60: List&#60;String&#62; s5List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61: s5List.Add(&#34;<span style="color:#8b0000;">Miami</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62: s5List.Add(&#34;<span style="color:#8b0000;">Jacksonville</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63: s5List.Add(&#34;<span style="color:#8b0000;">Tampa</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64: s5.Cities = s5List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65: statesList.Add(s5);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 66: </pre>
</pre>
<p>At XAML side we define one check box to display the Boolean variable. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Visited&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 	<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 			<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">CheckBox</span> <span style="color:#ff0000;">IsChecked</span>=<span style="color:#0000ff;">&#34;{Binding Visited}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: 		<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 	<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: </pre>
</pre>
<p>Similarly we define one more data template to define the cities list in combo box. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;100&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Cities&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 	<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 			<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ComboBox</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;75&#34;</span> <span style="color:#ff0000;">ItemsSource</span>=<span style="color:#0000ff;">&#34;{Binding Cities}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: 		<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 	<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: </pre>
</pre>
<p>Rest of the code is quite straight forward. Here is complete XAML code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;UIElement.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">local</span>=<span style="color:#0000ff;">&#34;clr-namespace:UIElement&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;ListView Example&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;525&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Style</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Key</span>=<span style="color:#0000ff;">&#34;myStyle&#34;</span> <span style="color:#ff0000;">TargetType</span>=<span style="color:#0000ff;">&#34;{x:Type ListViewItem}&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Background&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;FontSize&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;14&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Foreground&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;Green&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Style</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">ItemContainerStyle</span>=<span style="color:#0000ff;">&#34;{StaticResource myStyle}&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:                                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Visited&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">CheckBox</span> <span style="color:#ff0000;">IsChecked</span>=<span style="color:#0000ff;">&#34;{Binding Visited}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Name}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Capital&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Capital}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Nick Name&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Expander</span> <span style="color:#ff0000;">ExpandDirection</span>=<span style="color:#0000ff;">&#34;Right&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Green&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding NickName}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Expander</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;100&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;Cities&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ComboBox</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;75&#34;</span> <span style="color:#ff0000;">ItemsSource</span>=<span style="color:#0000ff;">&#34;{Binding Cities}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60: </pre>
</pre>
<p>And here is complete C# code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> UIElement
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             List&#60;StateInfo&#62; statesList = <span style="color:#0000ff;">new</span> List&#60;StateInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             StateInfo s1 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             s1.Name = &#34;<span style="color:#8b0000;">Maryland</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             s1.Capital = &#34;<span style="color:#8b0000;">Annapolis</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             s1.NickName = &#34;<span style="color:#8b0000;">Old Line State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             s1.Visited = <span style="color:#0000ff;">true</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:             List&#60;String&#62; s1List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             s1List.Add(&#34;<span style="color:#8b0000;">Frederick</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:             s1List.Add(&#34;<span style="color:#8b0000;">Baltimore</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:             s1List.Add(&#34;<span style="color:#8b0000;">Rockville</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:             s1List.Add(&#34;<span style="color:#8b0000;">Hagerstown</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:             s1.Cities = s1List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:             statesList.Add(s1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:             StateInfo s2 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:             s2.Name = &#34;<span style="color:#8b0000;">California</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:             s2.Capital = &#34;<span style="color:#8b0000;">Sacramento</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:             s2.NickName = &#34;<span style="color:#8b0000;">Golden State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:             s2.Visited = <span style="color:#0000ff;">true</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:             List&#60;String&#62; s2List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             s2List.Add(&#34;<span style="color:#8b0000;">Los Angeles</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             s2List.Add(&#34;<span style="color:#8b0000;">San Franscico</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:             s2List.Add(&#34;<span style="color:#8b0000;">San Deiago</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:             s2List.Add(&#34;<span style="color:#8b0000;">San Jose</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:             s2List.Add(&#34;<span style="color:#8b0000;">Fresno</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:             s2List.Add(&#34;<span style="color:#8b0000;">Long Beach</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:             s2.Cities = s2List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:             statesList.Add(s2);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:             StateInfo s3 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:             s3.Name = &#34;<span style="color:#8b0000;">Taxes</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:             s3.Capital = &#34;<span style="color:#8b0000;">Austin</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:             s3.NickName = &#34;<span style="color:#8b0000;">Lone Star State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60:             s3.Visited = <span style="color:#0000ff;">true</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61:             List&#60;String&#62; s3List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62:             s3List.Add(&#34;<span style="color:#8b0000;">Houston</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63:             s3List.Add(&#34;<span style="color:#8b0000;">Dallas</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64:             s3List.Add(&#34;<span style="color:#8b0000;">San Antonio</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65:             s3List.Add(&#34;<span style="color:#8b0000;">El Paso</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 66:             s3.Cities = s3List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 67:             statesList.Add(s3);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 68:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 69:             StateInfo s4 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 70:             s4.Name = &#34;<span style="color:#8b0000;">Ohio</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 71:             s4.Capital = &#34;<span style="color:#8b0000;">Columbus</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 72:             s4.NickName = &#34;<span style="color:#8b0000;">Buckeye State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 73:             s4.Visited = <span style="color:#0000ff;">false</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 74:             List&#60;String&#62; s4List = <span style="color:#0000ff;">new</span> List&#60;String&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 75:             s4List.Add(&#34;<span style="color:#8b0000;">Cleveland</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 76:             s4List.Add(&#34;<span style="color:#8b0000;">Cincinnati</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 77:             s4.Cities = s4List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 78:             statesList.Add(s4);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 79:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 80:             StateInfo s5 = <span style="color:#0000ff;">new</span> StateInfo();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 81:             s5.Name = &#34;<span style="color:#8b0000;">Florida</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 82:             s5.Capital = &#34;<span style="color:#8b0000;">Tallahassee</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 83:             s5.NickName = &#34;<span style="color:#8b0000;">Sunshine State</span>&#34;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 84:             s5.Visited = <span style="color:#0000ff;">false</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 85:             List&#60;String&#62; s5List = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 86:             s5List.Add(&#34;<span style="color:#8b0000;">Miami</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 87:             s5List.Add(&#34;<span style="color:#8b0000;">Jacksonville</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 88:             s5List.Add(&#34;<span style="color:#8b0000;">Tampa</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 89:             s5.Cities = s5List;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 90:             statesList.Add(s5);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 91:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 92:             list.ItemsSource = statesList;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 93:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 94:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 95:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 96:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> StateInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 97:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 98:         <span style="color:#0000ff;">private</span> List&#60;String&#62; list;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 99:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">100:         <span style="color:#0000ff;">public</span> StateInfo()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">101:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">102:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">103:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">104:         <span style="color:#0000ff;">public</span> StateInfo(String name, String capital, String nickName, String timeZone, Boolean visited)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">105:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">106:             Name = name;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">107:             Capital = capital;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">108:             NickName = nickName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">109:             TimeZone = timeZone;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">110:             Visited = visited;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">111:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">112:             list = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">113:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">114:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">115:         <span style="color:#0000ff;">public</span> String Name
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">116:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">117:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">118:         <span style="color:#0000ff;">public</span> String Capital
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">119:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">120:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">121:         <span style="color:#0000ff;">public</span> String NickName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">122:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">123:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">124:         <span style="color:#0000ff;">public</span> String TimeZone
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">125:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">126:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">127:         <span style="color:#0000ff;">public</span> Boolean Visited
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">128:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">129:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">130:         <span style="color:#0000ff;">public</span> List&#60;String&#62; Cities
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">131:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">132:             <span style="color:#0000ff;">get</span> { <span style="color:#0000ff;">return</span> list; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">133:             <span style="color:#0000ff;">set</span> { list = <span style="color:#0000ff;">value</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">134:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">135:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">136:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">137: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">138: </pre>
</pre>
<p>The output of this program would be something like this.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listviewoutput_06.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListViewOutput_06" border="0" alt="ListViewOutput_06" src="http://zamjad.files.wordpress.com/2009/11/listviewoutput_06_thumb.gif?w=525&#038;h=300" width="525" height="300" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[WPF : Utiliser des commandes dans un DataTemplate]]></title>
<link>http://wilfriedwoivre.wordpress.com/2009/11/21/wpf-utiliser-des-commandes-dans-un-datatemplate/</link>
<pubDate>Sat, 21 Nov 2009 01:56:07 +0000</pubDate>
<dc:creator>Wilfried Woivre</dc:creator>
<guid>http://wilfriedwoivre.wordpress.com/2009/11/21/wpf-utiliser-des-commandes-dans-un-datatemplate/</guid>
<description><![CDATA[Après une très longue période sans réutiliser de technologies tel que WPF ou Silverlight, on s’aperç]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Après une très longue période sans réutiliser de technologies tel que WPF ou Silverlight, on s’aperçoit que l’on perd très vite la main. C’est donc durant un projet éclair que je me suis décidé de refaire un petit projet en utilisant le MVVM.</p>
<p>C’est donc confiant que je commence mon code, que je me décide à le lancer au bout d’une heure, histoire de voir ce que ça donne en dehors du Designer WPF. Mon interface ressemble donc à ce que je veux, cependant je m’aperçois que certaines de mes commandes ne marchaient pas, je passe donc 10 bonnes minutes pour trouver ce qu’il se passe et enfin corriger.</p>
<p>On va donc voir dans cet article un moyen de contourner la déclaration des commandes dans un DataTemplate, sans pour autant perdre en fonctionnalité. </p>
<p>&#160;</p>
<p>Pour cette démonstration je vais utiliser comme base le template de MVVM qui vient de codeplex (<a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=14962#DownloadId=67235">WPF Model-View-ViewModel Toolkit 0.1</a>) que je vais modifier de tel sorte que ViewModelBase dérive de DependencyObject, et implémente deux méthodes abstraites qui sont OnViewReady(), et OnViewDispose(). On obtient donc ceci :</p>
<pre class="code"><span style="color:gray;">/// &#60;summary&#62;
/// </span><span style="color:green;">Provides common functionality for ViewModel classes
</span><span style="color:gray;">/// &#60;/summary&#62;
</span><span style="color:blue;">public abstract class </span><span style="color:#2b91af;">ViewModelBase </span>: <span style="color:#2b91af;">DependencyObject</span>, <span style="color:#2b91af;">INotifyPropertyChanged
</span>{
    <span style="color:blue;">public event </span><span style="color:#2b91af;">PropertyChangedEventHandler </span>PropertyChanged;

    <span style="color:blue;">protected void </span>OnPropertyChanged(<span style="color:blue;">string </span>propertyName)
    {
        <span style="color:#2b91af;">PropertyChangedEventHandler </span>handler = PropertyChanged;

        <span style="color:blue;">if </span>(handler != <span style="color:blue;">null</span>)
        {
            handler(<span style="color:blue;">this</span>, <span style="color:blue;">new </span><span style="color:#2b91af;">PropertyChangedEventArgs</span>(propertyName));
        }
    }

    <span style="color:blue;">public abstract void </span>OnViewReady();
    <span style="color:blue;">public abstract void </span>OnViewDispose();

}</pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Note les modifications apportées ici ne sont pas nécessaire pour la démonstration, mais grâce à cela vous pouvez utiliser les DependencyProperty dans votre ViewModel, et propager les évènements Loaded et Unloaded de vos vues, vers vos ViewModel. Voilà pour l’astuce du jour ! </p>
<p>Voici donc&#160; la commande que nous allons utiliser : </p>
<pre class="code"><span style="color:blue;">#region </span>GestionCommandes
<span style="color:blue;">private </span><span style="color:#2b91af;">DelegateCommand</span>&#60;Models.<span style="color:#2b91af;">Person</span>&#62; editPersonCommand;

<span style="color:blue;">public </span><span style="color:#2b91af;">ICommand </span>EditPersonCommand
{
    <span style="color:blue;">get
    </span>{
        <span style="color:blue;">if </span>(editPersonCommand == <span style="color:blue;">null</span>)
            editPersonCommand = <span style="color:blue;">new </span><span style="color:#2b91af;">DelegateCommand</span>&#60;Models.<span style="color:#2b91af;">Person</span>&#62;(EditPerson);
        <span style="color:blue;">return </span>editPersonCommand;
    }
}

<span style="color:blue;">private void </span>EditPerson(Models.<span style="color:#2b91af;">Person </span>person)
{
    <span style="color:#2b91af;">MessageBox</span>.Show(<span style="color:#a31515;">&#34;Ici on éditera la personne&#34;</span>, <span style="color:#a31515;">&#34;&#34;</span>, <span style="color:#2b91af;">MessageBoxButton</span>.OK);
}
<span style="color:blue;">#endregion </span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Bon maintenant, affichons nos données dans la vue au pas à pas. Après un binding initial on obtient quelque chose du style </p>
<pre class="code"><span style="color:blue;">&#60;</span><span style="color:#a31515;">Window </span><span style="color:red;">x</span><span style="color:blue;">:</span><span style="color:red;">Class</span><span style="color:blue;">=&#34;WpfModelViewApplication3.Views.MainView&#34;
    </span><span style="color:red;">xmlns</span><span style="color:blue;">=&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;
    </span><span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">x</span><span style="color:blue;">=&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;
    </span><span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">c</span><span style="color:blue;">=&#34;clr-namespace:WpfModelViewApplication3.Commands&#34;
    </span><span style="color:red;">Title</span><span style="color:blue;">=&#34;Main Window&#34; </span><span style="color:red;">Height</span><span style="color:blue;">=&#34;400&#34; </span><span style="color:red;">Width</span><span style="color:blue;">=&#34;800&#34;&#62;

    &#60;</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;
        &#60;</span><span style="color:#a31515;">ListBox </span><span style="color:red;">ItemsSource</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">People</span><span style="color:blue;">}&#34; /&#62;
    &#60;/</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;
&#60;/</span><span style="color:#a31515;">Window</span><span style="color:blue;">&#62;
</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Avec pour interface générée : </p>
<p><a href="http://wilfriedwoivre.files.wordpress.com/2009/11/image2.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="image" border="0" alt="image" src="http://wilfriedwoivre.files.wordpress.com/2009/11/image_thumb2.png?w=493&#038;h=317" width="493" height="317" /></a></p>
<p>Bon ceci, n’étant pas très lisible pour un client, on va donc créer un DataTemplate. Or pour des raisons de lecture, nous allons ajouter ce DataTemplate en ressources de la fenêtre. </p>
<p>Donc confiant, j’écris ceci :</p>
<pre class="code"><span style="color:blue;">&#60;</span><span style="color:#a31515;">Window.Resources</span><span style="color:blue;">&#62;
    &#60;</span><span style="color:#a31515;">DataTemplate </span><span style="color:red;">DataType</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">x</span><span style="color:blue;">:</span><span style="color:#a31515;">Type </span><span style="color:red;">localModel</span><span style="color:blue;">:</span><span style="color:red;">Person</span><span style="color:blue;">}&#34;&#62;
        &#60;</span><span style="color:#a31515;">StackPanel </span><span style="color:red;">Orientation</span><span style="color:blue;">=&#34;Horizontal&#34;&#62;
            &#60;</span><span style="color:#a31515;">Label </span><span style="color:red;">Content</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">FirstName</span><span style="color:blue;">}&#34; /&#62;
            &#60;</span><span style="color:#a31515;">Button </span><span style="color:red;">Content</span><span style="color:blue;">=&#34;Modifier&#34; </span><span style="color:red;">Margin</span><span style="color:blue;">=&#34;5 0&#34; </span><span style="color:red;">Command</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">EditPersonCommand</span><span style="color:blue;">}&#34; </span><span style="color:red;">CommandParameter</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding</span><span style="color:blue;">}&#34; /&#62;
        &#60;/</span><span style="color:#a31515;">StackPanel</span><span style="color:blue;">&#62;
    &#60;/</span><span style="color:#a31515;">DataTemplate</span><span style="color:blue;">&#62;
&#60;/</span><span style="color:#a31515;">Window.Resources</span><span style="color:blue;">&#62;

&#60;</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;
    &#60;</span><span style="color:#a31515;">ListBox </span><span style="color:red;">ItemsSource</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">People</span><span style="color:blue;">}&#34; /&#62;
&#60;/</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>J’ai donc mon interface qui change en conséquence : </p>
<p><a href="http://wilfriedwoivre.files.wordpress.com/2009/11/image3.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="image" border="0" alt="image" src="http://wilfriedwoivre.files.wordpress.com/2009/11/image_thumb3.png?w=353&#038;h=321" width="353" height="321" /></a></p>
<p>Le problème se situe en fait lorsque je clique sur le bouton Modifier, en effet rien ne se produit. J’ai donc regardé si lors de la construction de la fenêtre il allait bien me chercher ma commande, mais il ignora mon point d’arrêt dans Visual Studio.</p>
<p>Alors l’astuce facile à réaliser avec ce template est d’utiliser leur CommandReference, de tel sorte : </p>
<pre class="code"><span style="color:blue;">&#60;</span><span style="color:#a31515;">Window.Resources</span><span style="color:blue;">&#62;
    &#60;</span><span style="color:#a31515;">c</span><span style="color:blue;">:</span><span style="color:#a31515;">CommandReference </span><span style="color:red;">x</span><span style="color:blue;">:</span><span style="color:red;">Key</span><span style="color:blue;">=&#34;EditPerson&#34; </span><span style="color:red;">Command</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">EditPersonCommand</span><span style="color:blue;">}&#34; /&#62;

    &#60;</span><span style="color:#a31515;">DataTemplate </span><span style="color:red;">DataType</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">x</span><span style="color:blue;">:</span><span style="color:#a31515;">Type </span><span style="color:red;">localModel</span><span style="color:blue;">:</span><span style="color:red;">Person</span><span style="color:blue;">}&#34;&#62;
        &#60;</span><span style="color:#a31515;">StackPanel </span><span style="color:red;">Orientation</span><span style="color:blue;">=&#34;Horizontal&#34;&#62;
            &#60;</span><span style="color:#a31515;">Label </span><span style="color:red;">Content</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">FirstName</span><span style="color:blue;">}&#34; /&#62;
            &#60;</span><span style="color:#a31515;">Button </span><span style="color:red;">Content</span><span style="color:blue;">=&#34;Modifier&#34; </span><span style="color:red;">Margin</span><span style="color:blue;">=&#34;5 0&#34; </span><span style="color:red;">Command</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">StaticResource </span><span style="color:red;">EditPerson</span><span style="color:blue;">}&#34; </span><span style="color:red;">CommandParameter</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding</span><span style="color:blue;">}&#34; /&#62;
        &#60;/</span><span style="color:#a31515;">StackPanel</span><span style="color:blue;">&#62;
    &#60;/</span><span style="color:#a31515;">DataTemplate</span><span style="color:blue;">&#62;
&#60;/</span><span style="color:#a31515;">Window.Resources</span><span style="color:blue;">&#62;

&#60;</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;
    &#60;</span><span style="color:#a31515;">ListBox </span><span style="color:red;">ItemsSource</span><span style="color:blue;">=&#34;{</span><span style="color:#a31515;">Binding </span><span style="color:red;">People</span><span style="color:blue;">}&#34; /&#62;
&#60;/</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;</span></pre>
<p><a href="http://11011.net/software/vspaste"></a></p>
<p>Là, notre code fonctionne comme on le souhaitait, et l’on récupère bien entendu le bon membre lors du déclenchement de la commande. En fait, ce qui a changé, nous avons déclaré la command, dans l’objet CommandReference. Notre bouton peut donc appeler la commande via le nom qu’on lui a donné. En effet, il passe par une ressource statique qui existe, et non une donnée dynamique comme il était question dans le DataTemplate. </p>
<p>Vous pouvez retrouvez la CommandReference dans le MVVM Toolkit, ce qui nous prouve encore une fois qu’avec des Toolkit bien pensé on optimise fortement notre temps de développement.</p>
<p>En espérant que cet article vous aide dans de futurs développement !</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Des nouvelles de la PDC 2009 : Silverlight 4 Beta]]></title>
<link>http://wilfriedwoivre.wordpress.com/2009/11/21/des-nouvelles-de-la-pdc-2009-silverlight-4-beta/</link>
<pubDate>Fri, 20 Nov 2009 23:26:37 +0000</pubDate>
<dc:creator>Wilfried Woivre</dc:creator>
<guid>http://wilfriedwoivre.wordpress.com/2009/11/21/des-nouvelles-de-la-pdc-2009-silverlight-4-beta/</guid>
<description><![CDATA[Et voilà, comme je le suppose, vous avez tous du apprendre que Silverlight 4 Beta est disponible pou]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Et voilà, comme je le suppose, vous avez tous du apprendre que Silverlight 4 Beta est disponible pour nous les développeurs ! Et sinon vous n’étiez pas au courant, voilà qui est fait.</p>
<p>Alors je ne vais pas vous lister toutes les nouveautés de Silverlight 4, vu que d’autres l’ont déjà fait !</p>
<p>Mais voici un ensemble de liens ou vous pourrez voir tous les avantages de cette nouvelle version.</p>
<p>&#160;</p>
<p>Le blog de Tim Heueur bien entendu : <a href="http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx">http://timheuer.com/blog/archive/2009/11/18/whats-new-in-silverlight-4-complete-guide-new-features.aspx</a></p>
<p>Et la série d’article de Mike Taulty (qui soit dit en passant à réussi à faire perdre la tête à mon Netvibes)</p>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-beta-announced-at-pdc.aspx">Silverlight 4: Beta Announced at PDC</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-trusted-applications.aspx">Silverlight 4 Rough Notes: Trusted Applications</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-camera-and-microphone-support.aspx">Silverlight 4 Rough Notes: Camera and Microphone Support</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-printing.aspx">Silverlight 4 Rough Notes: Printing</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-html-hosting-in-the-webbrowser-control.aspx">Silverlight 4 Rough Notes: HTML Hosting in the WebBrowser Control</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-notification-windows.aspx">Silverlight 4 Rough Notes: Notification Windows</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-richtextarea.aspx">Silverlight 4 Rough Notes: RichTextArea</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-networking.aspx">Silverlight 4 Rough Notes: Networking</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-flowdirection.aspx">Silverlight 4 Rough Notes: FlowDirection</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-clipboard-access.aspx">Silverlight 4 Rough Notes: Clipboard Access</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-silverlight-as-a-drop-target.aspx">Silverlight 4 Rough Notes: Silverlight as a Drop Target</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-right-mouse-button-support.aspx">Silverlight 4 Rough Notes: Right Mouse Button Support</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-binding.aspx">Silverlight 4 Rough Notes: Binding</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-binding-and-idataerrorinfo.aspx">Silverlight 4 Rough Notes: Binding and IDataErrorInfo</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-binding-with-inotifydataerrorinfo.aspx">Silverlight 4 Rough Notes: Binding with INotifyDataErrorInfo</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-a-word-for-visual-studio-2010.aspx">Silverlight 4 Rough Notes: A Word for Visual Studio 2010</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-styles.aspx">Silverlight 4 Rough Notes: Styles</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-commanding.aspx">Silverlight 4 Rough Notes: Commanding</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-customising-the-window.aspx">Silverlight 4 Rough Notes: Customising the Window</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-animating-items-into-out-of-itemscontrols.aspx">Silverlight 4 Rough Notes: Animating Items Into/Out Of ItemsControls</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-html-interop-amp-dynamic-language-features.aspx">Silverlight 4 Rough Notes: HTML interop &#38; dynamic language features</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-data-grid-enhancements.aspx">Silverlight 4 Rough Notes: Data Grid Enhancements</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-taking-control-of-navigation.aspx">Silverlight 4 Rough Notes: Taking Control of Navigation</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-selectedvalue.aspx">Silverlight 4 Rough Notes: SelectedValue</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-mousewheel-support-in-controls.aspx">Silverlight 4 Rough Notes: Mousewheel Support in Controls</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-textblock-with-trimming.aspx">Silverlight 4 Rough Notes: TextBlock with Trimming</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-compositetransform.aspx">Silverlight 4 Rough Notes: CompositeTransform</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-viewbox.aspx">Silverlight 4 Rough Notes: Viewbox</a></h6>
<h6><a href="http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/11/18/silverlight-4-rough-notes-managed-extensibility-framework.aspx">Silverlight 4 Rough Notes: Managed Extensibility Framework</a></h6>
<p>&#160;</p>
<p>Et voilà de quoi occuper longuement votre weekend, et le mien aussi d’ailleurs.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Silverlight4 Beta Availability for Developers]]></title>
<link>http://rajramabadran.wordpress.com/2009/11/20/silverlight4-beta-availability-for-developers/</link>
<pubDate>Fri, 20 Nov 2009 05:40:41 +0000</pubDate>
<dc:creator>rajramabadran</dc:creator>
<guid>http://rajramabadran.wordpress.com/2009/11/20/silverlight4-beta-availability-for-developers/</guid>
<description><![CDATA[Silverlight 4 Beta Information Earlier this week at PDC09 in Los Angeles we unveiled a Beta version ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://rajramabadran.files.wordpress.com/2009/11/image3.png"><img style="display:inline;border:0;" title="image" src="http://rajramabadran.files.wordpress.com/2009/11/image_thumb3.png?w=244&#038;h=116" border="0" alt="image" width="244" height="116" /></a></p>
<p>Silverlight 4 Beta Information</p>
<p>Earlier this week at <a href="http://microsoftpdc.com/">PDC09</a> in Los Angeles we unveiled a Beta version Silverlight 4. This latest version delivers hundreds of features and controls that, when combined with the continued innovation in Microsoft’s world-class tools for designers and developers — Microsoft Visual Studio and Microsoft Expression Blend – present the leading edge in rapid, powerful application development. With printing support, rich reporting and charting, and integration with back-end systems and server products including Microsoft SharePoint, Silverlight is ready for business.</p>
<p><a name="whatsnew"></a>What’s New in Silverlight 4 Beta?</p>
<p>Silverlight 4 delivers a full suite of powerful capabilities to business application developers, bringing the best-of-breed .NET platform to browser-based experiences. Silverlight provides an ideal platform for developing and deploying modern business applications for both customer facing and staff-facing applications.</p>
<p>To learn more about beta release here are some good resource:</p>
<p><a href="http://silverlight.net/getstarted/silverlight-4-beta/">http://silverlight.net/getstarted/silverlight-4-beta/</a></p>
<p><a href="http://channel9.msdn.com/learn/courses/Silverlight4/Overview/Overview/">http://channel9.msdn.com/learn/courses/Silverlight4/Overview/Overview/</a></p>
<p><a href="http://channel9.msdn.com/learn/courses/Silverlight4/Overview/WhatsNew/">http://channel9.msdn.com/learn/courses/Silverlight4/Overview/WhatsNew/</a></p>
<p>Additionally the Day#2 keynote announcement of Silverligh4 beta release from PDC09 is available on demand at:</p>
<p><a href="http://microsoftpdc.com/Sessions/KEY02">http://microsoftpdc.com/Sessions/KEY02</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using Expender control inside List View]]></title>
<link>http://zamjad.wordpress.com/2009/11/19/using-expender-control-inside-list-view/</link>
<pubDate>Fri, 20 Nov 2009 04:20:41 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/19/using-expender-control-inside-list-view/</guid>
<description><![CDATA[Till now are are applying template only at the list view header. This time we are going to apply tem]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>Till now are are applying template only at the list view header. This time we are going to apply template in the list view item. In this example we are going to insert the expender control inside the cell of the grid view. We are using data template for this purpose. We are going to apply on GridViewColumn and use its CellTemplate property. CellTemplate is a DataTemplate type property. Here is a piece of code to insert expender inside the list view. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 	<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Expander</span> <span style="color:#ff0000;">ExpandDirection</span>=<span style="color:#0000ff;">&#34;Right&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 			<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Green&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding NickName}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: 		<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Expander</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 	<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: </pre>
</pre>
<p>Rest of the code is almost same as we saw earlier. Here is a complete XAML code of the project. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;UIElement.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">local</span>=<span style="color:#0000ff;">&#34;clr-namespace:UIElement&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;ListView Example&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;400&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Style</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Key</span>=<span style="color:#0000ff;">&#34;myStyle&#34;</span> <span style="color:#ff0000;">TargetType</span>=<span style="color:#0000ff;">&#34;{x:Type ListViewItem}&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Background&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;FontSize&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;14&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Foreground&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;Green&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Style</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">ItemContainerStyle</span>=<span style="color:#0000ff;">&#34;{StaticResource myStyle}&#34;</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:                                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Name}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Capital&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Capital}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Nick Name&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Expander</span> <span style="color:#ff0000;">ExpandDirection</span>=<span style="color:#0000ff;">&#34;Right&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Green&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding NickName}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Expander</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47: </pre>
</pre>
<p>C# code of this project is also same as previous project. Here is complete C# code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> UIElement
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             List&#60;StateInfo&#62; statesList = <span style="color:#0000ff;">new</span> List&#60;StateInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Maryland</span>&#34;, &#34;<span style="color:#8b0000;">Annapolis</span>&#34;, &#34;<span style="color:#8b0000;">Old Line State</span>&#34;, &#34;<span style="color:#8b0000;">Eastern</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">California</span>&#34;, &#34;<span style="color:#8b0000;">Sacramento</span>&#34;, &#34;<span style="color:#8b0000;">Golden State</span>&#34;, &#34;<span style="color:#8b0000;">Pacific</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Washington</span>&#34;, &#34;<span style="color:#8b0000;">Olympia</span>&#34;, &#34;<span style="color:#8b0000;">Ever Green State</span>&#34;, &#34;<span style="color:#8b0000;">Pacific</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Taxes</span>&#34;, &#34;<span style="color:#8b0000;">Austin</span>&#34;, &#34;<span style="color:#8b0000;">Lone Star State</span>&#34;, &#34;<span style="color:#8b0000;">Central</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">New York</span>&#34;, &#34;<span style="color:#8b0000;">Albany</span>&#34;, &#34;<span style="color:#8b0000;">Empire State</span>&#34;, &#34;<span style="color:#8b0000;">Eastern</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             list.ItemsSource = statesList;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> StateInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:         <span style="color:#0000ff;">public</span> StateInfo()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:         <span style="color:#0000ff;">public</span> StateInfo(String name, String capital, String nickName, String timeZone)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:             Name = name;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             Capital = capital;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             NickName = nickName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:             TimeZone = timeZone;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:         <span style="color:#0000ff;">public</span> String Name
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         <span style="color:#0000ff;">public</span> String Capital
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:         <span style="color:#0000ff;">public</span> String NickName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61:         <span style="color:#0000ff;">public</span> String TimeZone
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65: </pre>
</pre>
<p>Here is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listviewoutput_05.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListViewOutput_05" border="0" alt="ListViewOutput_05" src="http://zamjad.files.wordpress.com/2009/11/listviewoutput_05_thumb.gif?w=400&#038;h=300" width="400" height="300" /></a> </p>
<p>With the help of horizontal expender, now we can make the state nick name demand base, means user can see the nick name of his/her selected states. </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Apply style to list view items]]></title>
<link>http://zamjad.wordpress.com/2009/11/18/apply-style-to-list-items/</link>
<pubDate>Thu, 19 Nov 2009 03:37:56 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/18/apply-style-to-list-items/</guid>
<description><![CDATA[We already applied the data template to the header item, but the content of the list view is still v]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We already applied the data template to the header item, but the content of the list view is still very boring. Now we are going to apply some style to the list view items. Here we are going to define style in windows resource section of the&#160; XAML and then use the StaticResource markup extension to use that style. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 	<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Style</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Key</span>=<span style="color:#0000ff;">&#34;myStyle&#34;</span> <span style="color:#ff0000;">TargetType</span>=<span style="color:#0000ff;">&#34;{x:Type ListViewItem}&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Background&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;FontSize&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;14&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Foreground&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;Green&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 	<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Style</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: </pre>
</pre>
<p>We select “myStyle” name of our style and apply it on all ListViewItems. In this style, we are changing three properties of ListViewItem. We are changing its font size, foreground color and its background color. </p>
<p>After that we apply those changes in ItemContainerStyle property of ListView which has a style type.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">ItemContainerStyle</span>=<span style="color:#0000ff;">&#34;{StaticResource myStyle}&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 		  <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: </pre>
</pre>
<p>Here is a complete XAML code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;UIElement.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">local</span>=<span style="color:#0000ff;">&#34;clr-namespace:UIElement&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;ListView Example&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;400&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Style</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Key</span>=<span style="color:#0000ff;">&#34;myStyle&#34;</span> <span style="color:#ff0000;">TargetType</span>=<span style="color:#0000ff;">&#34;{x:Type ListViewItem}&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Background&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;AliceBlue&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;FontSize&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;14&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Setter</span> <span style="color:#ff0000;">Property</span>=<span style="color:#0000ff;">&#34;Foreground&#34;</span> <span style="color:#ff0000;">Value</span>=<span style="color:#0000ff;">&#34;Green&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Style</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window.Resources</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">ItemContainerStyle</span>=<span style="color:#0000ff;">&#34;{StaticResource myStyle}&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:                   <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:                                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontSize</span>=<span style="color:#0000ff;">&#34;14&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Name}&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn.CellTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridViewColumn</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Capital&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Capital}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Nick Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=NickName}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49: </pre>
</pre>
<p>Its C# code is same as previous project. Here is complete C# coding of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> UIElement
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             List&#60;StateInfo&#62; statesList = <span style="color:#0000ff;">new</span> List&#60;StateInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Maryland</span>&#34;, &#34;<span style="color:#8b0000;">Annapolis</span>&#34;, &#34;<span style="color:#8b0000;">Old Line State</span>&#34;, &#34;<span style="color:#8b0000;">Eastern</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">California</span>&#34;, &#34;<span style="color:#8b0000;">Sacramento</span>&#34;, &#34;<span style="color:#8b0000;">Golden State</span>&#34;, &#34;<span style="color:#8b0000;">Pacific</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Washington</span>&#34;, &#34;<span style="color:#8b0000;">Olympia</span>&#34;, &#34;<span style="color:#8b0000;">Ever Green State</span>&#34;, &#34;<span style="color:#8b0000;">Pacific</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Taxes</span>&#34;, &#34;<span style="color:#8b0000;">Austin</span>&#34;, &#34;<span style="color:#8b0000;">Lone Star State</span>&#34;, &#34;<span style="color:#8b0000;">Central</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">New York</span>&#34;, &#34;<span style="color:#8b0000;">Albany</span>&#34;, &#34;<span style="color:#8b0000;">Empire State</span>&#34;, &#34;<span style="color:#8b0000;">Eastern</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             list.ItemsSource = statesList;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> StateInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:         <span style="color:#0000ff;">public</span> StateInfo()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:         <span style="color:#0000ff;">public</span> StateInfo(String name, String capital, String nickName, String timeZone)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:             Name = name;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             Capital = capital;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             NickName = nickName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:             TimeZone = timeZone;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:         <span style="color:#0000ff;">public</span> String Name
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         <span style="color:#0000ff;">public</span> String Capital
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:         <span style="color:#0000ff;">public</span> String NickName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61:         <span style="color:#0000ff;">public</span> String TimeZone
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65: </pre>
</pre>
<p>Here is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listviewoutput_04.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListViewOutput_04" border="0" alt="ListViewOutput_04" src="http://zamjad.files.wordpress.com/2009/11/listviewoutput_04_thumb.gif?w=404&#038;h=304" width="404" height="304" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using data template with List view header]]></title>
<link>http://zamjad.wordpress.com/2009/11/17/using-data-template-with-list-view-header/</link>
<pubDate>Wed, 18 Nov 2009 04:43:33 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/17/using-data-template-with-list-view-header/</guid>
<description><![CDATA[We just studied the basic functionality of list view and how we can display data in multiple columns]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We just studied the basic functionality of list view and how we can display data in multiple columns in the list view. But we display our data in very simple and default format. Let’s explore it little bit more and try to customize the its display. At this stage we are going to change the header formatting and apply the data template at the header level. </p>
<p>To change the display of the header, we are going to set the column header template data type. Here is a piece of code to set the data template for the header of the list view. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: 	<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: 		<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: 			<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: 				<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: 					<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: 					<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: 				<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: 			<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: 			<span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: 		<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: 	<span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14: </pre>
</pre>
<p>ColumnHeaderTemplate is a DataTemplate type property of GridView class. Here is complete XAML code of the project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;UIElement.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">local</span>=<span style="color:#0000ff;">&#34;clr-namespace:UIElement&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;ListView Example&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;400&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:                             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border</span> <span style="color:#ff0000;">BorderBrush</span>=<span style="color:#0000ff;">&#34;Brown&#34;</span> <span style="color:#ff0000;">BorderThickness</span>=<span style="color:#0000ff;">&#34;2&#34;</span> <span style="color:#ff0000;">CornerRadius</span>=<span style="color:#0000ff;">&#34;5&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:                                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;0&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;Wheat&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:                                         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GradientStop</span> <span style="color:#ff0000;">Offset</span>=<span style="color:#0000ff;">&#34;1&#34;</span> <span style="color:#ff0000;">Color</span>=<span style="color:#0000ff;">&#34;LightCoral&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:                                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">LinearGradientBrush</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:                                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border.Background</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:                                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">TextBlock</span> <span style="color:#ff0000;">Foreground</span>=<span style="color:#0000ff;">&#34;Blue&#34;</span> <span style="color:#ff0000;">FontWeight</span>=<span style="color:#0000ff;">&#34;Bold&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">Text</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:                             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Border</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:                         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">DataTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:                     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView.ColumnHeaderTemplate</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Name}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Capital&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Capital}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Nick Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=NickName}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32: </pre>
</pre>
<p>Here is a complete C# code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> UIElement
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             List&#60;StateInfo&#62; statesList = <span style="color:#0000ff;">new</span> List&#60;StateInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Maryland</span>&#34;, &#34;<span style="color:#8b0000;">Annapolis</span>&#34;, &#34;<span style="color:#8b0000;">Old Line State</span>&#34;, &#34;<span style="color:#8b0000;">Eastern</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">California</span>&#34;, &#34;<span style="color:#8b0000;">Sacramento</span>&#34;, &#34;<span style="color:#8b0000;">Golden State</span>&#34;, &#34;<span style="color:#8b0000;">Pacific</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Washington</span>&#34;, &#34;<span style="color:#8b0000;">Olympia</span>&#34;, &#34;<span style="color:#8b0000;">Ever Green State</span>&#34;, &#34;<span style="color:#8b0000;">Pacific</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Taxes</span>&#34;, &#34;<span style="color:#8b0000;">Austin</span>&#34;, &#34;<span style="color:#8b0000;">Lone Star State</span>&#34;, &#34;<span style="color:#8b0000;">Central</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">New York</span>&#34;, &#34;<span style="color:#8b0000;">Albany</span>&#34;, &#34;<span style="color:#8b0000;">Empire State</span>&#34;, &#34;<span style="color:#8b0000;">Eastern</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             list.ItemsSource = statesList;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> StateInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:         <span style="color:#0000ff;">public</span> StateInfo()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:         <span style="color:#0000ff;">public</span> StateInfo(String name, String capital, String nickName, String timeZone)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:             Name = name;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             Capital = capital;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             NickName = nickName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:             TimeZone = timeZone;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:         <span style="color:#0000ff;">public</span> String Name
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         <span style="color:#0000ff;">public</span> String Capital
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:         <span style="color:#0000ff;">public</span> String NickName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61:         <span style="color:#0000ff;">public</span> String TimeZone
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 62:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 63:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 64: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 65: </pre>
</pre>
<p>Here is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listviewoutput_03.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListViewOutput_03" border="0" alt="ListViewOutput_03" src="http://zamjad.files.wordpress.com/2009/11/listviewoutput_03_thumb.gif?w=400&#038;h=300" width="400" height="300" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Feature: Transportable Interfaces]]></title>
<link>http://codenameclarity.wordpress.com/2009/11/18/feature-transportable-interfaces/</link>
<pubDate>Wed, 18 Nov 2009 02:08:40 +0000</pubDate>
<dc:creator>clintpearson</dc:creator>
<guid>http://codenameclarity.wordpress.com/2009/11/18/feature-transportable-interfaces/</guid>
<description><![CDATA[This feature is a really big one, and could prove the most useful feature (other than data sharing).]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>This feature is a really big one, and could prove the most useful feature (other than data sharing).</p>
<p>Basically imagine you have an application that allows you to tag people in a photo, but your photo management application<br />
doesn&#8217;t allow this, well providing they both support Clarity and they follow the data guidelines correctly the two applications should be able to share their photos.</p>
<p>Now, this would normally be fine, but nobody wants to have to open another application and worry about navigating around it just to do one task, what if the application could be run when needed / hide in the background?</p>
<p>Well this is one way of doing it, and the application could simply make itself visible when the user wants to use it; but this also isn&#8217;t ideal.</p>
<p>Wouldn&#8217;t it be great if the photo manager application could &#8220;pull-in&#8221; the part of the applications interface that allows the user to tag photos, the Clarity system would then communicate all of the data and events between the two parties, and in a practically transparent manner!</p>
<p>This, in theory, using the Clarity system could also be done over the internet, you have some photos you took at a party and want to know who&#8217;s in them? As long as your friends have the same application they could (providing the application supports it), dive right into your photo library and tag it remotely, all using code that is running on your machine!</p>
<p>This technology would be initially fairly basic, and restricted to WPF for the simple fact that XAML can be so easily removed from the application logic, and the binding system provides a very quick way of doing a lot of what this system would require.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[ListView Control Revisited]]></title>
<link>http://zamjad.wordpress.com/2009/11/16/listview-control-revisited/</link>
<pubDate>Tue, 17 Nov 2009 04:40:37 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/16/listview-control-revisited/</guid>
<description><![CDATA[We just saw the example of list view control. In that example we saw list view just like a list box.]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>We just saw the example of list view control. In that example we saw list view just like a list box. Now let’s explore it little bit more and see the multiple columns in list view and do the data binding with the user define type. Here is a XAML code to display the multiple columns in the list view. </p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;UIElement.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">local</span>=<span style="color:#0000ff;">&#34;clr-namespace:UIElement&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;ListView Example&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;400&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Name}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Capital&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=Capital}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;State Nick Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding Path=NickName}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18: </pre>
</pre>
<p>Let’s take a look our old example of State info class. In this C# code we are defining list of state info class and fill it with some data before doing data binding. Here is a complete C# code of this project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> UIElement
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:             List&#60;StateInfo&#62; statesList = <span style="color:#0000ff;">new</span> List&#60;StateInfo&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Maryland</span>&#34;, &#34;<span style="color:#8b0000;">Annapolis</span>&#34;, &#34;<span style="color:#8b0000;">Old Line State</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">California</span>&#34;, &#34;<span style="color:#8b0000;">Sacramento</span>&#34;, &#34;<span style="color:#8b0000;">Golden State</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Washington</span>&#34;, &#34;<span style="color:#8b0000;">Olympia</span>&#34;, &#34;<span style="color:#8b0000;">Ever Green State</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">Taxes</span>&#34;, &#34;<span style="color:#8b0000;">Austin</span>&#34;, &#34;<span style="color:#8b0000;">Lone Star State</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             statesList.Add(<span style="color:#0000ff;">new</span> StateInfo(&#34;<span style="color:#8b0000;">New York</span>&#34;, &#34;<span style="color:#8b0000;">Albany</span>&#34;, &#34;<span style="color:#8b0000;">Empire State</span>&#34;));
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             list.ItemsSource = statesList;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> StateInfo
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40:         <span style="color:#0000ff;">public</span> StateInfo()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 41:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 42:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 43:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 44:         <span style="color:#0000ff;">public</span> StateInfo(String name, String capital, String nickName)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 45:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 46:             Name = name;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 47:             Capital = capital;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 48:             NickName = nickName;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 49:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 50:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 51:         <span style="color:#0000ff;">public</span> String Name
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 52:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 53:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 54:         <span style="color:#0000ff;">public</span> String Capital
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 55:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 56:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 57:         <span style="color:#0000ff;">public</span> String NickName
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 58:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 59:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 60: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 61: </pre>
</pre>
<p>Here is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listviewoutput_02.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListViewOutput_02" border="0" alt="ListViewOutput_02" src="http://zamjad.files.wordpress.com/2009/11/listviewoutput_02_thumb.gif?w=400&#038;h=300" width="400" height="300" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Imageboard viewer almost done &ndash; Needs tweaking]]></title>
<link>http://fragiledevelopment.wordpress.com/2009/11/16/imageboard-viewer-almost-done-needs-tweaking/</link>
<pubDate>Mon, 16 Nov 2009 18:10:52 +0000</pubDate>
<dc:creator>Viktor Larsson</dc:creator>
<guid>http://fragiledevelopment.wordpress.com/2009/11/16/imageboard-viewer-almost-done-needs-tweaking/</guid>
<description><![CDATA[As I mentioned before, I’ve been working on an image extractor for a specific image board as a way t]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>As I mentioned before, I’ve been working on an image extractor for a specific image board as a way to hone my .net skills. It’s almost done in the sense that “it works on my computer”. </p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image5.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="image" border="0" alt="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb5.png?w=289&#038;h=217" width="289" height="217" /></a> </p>
<p>This is the look of it at the moment. The gradient background is kind of an inside joke and those of you who get it, good for you. </p>
<p>The idea is for users to be able to look at multiple pages of image content without having to click through pages or read lots of useless banter. Take for instance this wallpaper-board. The user can request any number of available pages to be presented and then click on an image to see it in full resolution. Very effective.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image6.png"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="image" border="0" alt="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb6.png?w=441&#038;h=303" width="441" height="303" /></a> </p>
<p>My problem at this point is that since I developed the app using Visual Studio 2010, all references are to .net framework 4.0 and unusable to most people. A friend of mine who tested the application also complained about it stopping when trying to save the pictures. I guess the apps main thread stalls while downloading. That’s something else I’ll have to look at. </p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using ListView control]]></title>
<link>http://zamjad.wordpress.com/2009/11/15/using-listview-control/</link>
<pubDate>Mon, 16 Nov 2009 04:14:30 +0000</pubDate>
<dc:creator>zamjad</dc:creator>
<guid>http://zamjad.wordpress.com/2009/11/15/using-listview-control/</guid>
<description><![CDATA[ListView control is inherited by ListBox class and it contains all the functionality of List Box cla]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>ListView control is inherited by ListBox class and it contains all the functionality of List Box class. Here is a class diagram of ListView class.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listbox1.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListBox" border="0" alt="ListBox" src="http://zamjad.files.wordpress.com/2009/11/listbox_thumb1.gif?w=219&#038;h=402" width="219" height="402" /></a> </p>
<p>List view define a property View that define the presentation of the List view. WPF already provide one presentation for ListBox class named GridView. If we want to define our own presentation then we have to inherit our class from ViewBase class. ViewBase is an abstract class and View Property of ListView class has the ViewBase data type. Here is a class diagram to explain this. </p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listview.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListView" border="0" alt="ListView" src="http://zamjad.files.wordpress.com/2009/11/listview_thumb.gif?w=717&#038;h=653" width="717" height="653" /></a> </p>
<p>Now lets take a look at simple usage of GridView class. Our C# code is very similar to List box example there&#160; we define list of string. Here is C# code of this.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Linq;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">using</span> System.Text;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">using</span> System.Windows.Controls;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7: <span style="color:#0000ff;">using</span> System.Windows.Data;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8: <span style="color:#0000ff;">using</span> System.Windows.Documents;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9: <span style="color:#0000ff;">using</span> System.Windows.Input;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">using</span> System.Windows.Media;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11: <span style="color:#0000ff;">using</span> System.Windows.Media.Imaging;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12: <span style="color:#0000ff;">using</span> System.Windows.Navigation;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13: <span style="color:#0000ff;">using</span> System.Windows.Shapes;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">namespace</span> UIElement
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 17:     <span style="color:#808080;">/// &#60;summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 18:     <span style="color:#808080;">/// Interaction logic for Window1.xaml</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 19:     <span style="color:#808080;">/// &#60;/summary&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 20:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> Window1 : Window
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 21:     {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 22:         <span style="color:#0000ff;">public</span> List&#60;String&#62; items
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 23:         { <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 24:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 25:         <span style="color:#0000ff;">public</span> Window1()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 26:         {
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 27:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 28:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 29:             items = <span style="color:#0000ff;">new</span> List&#60;<span style="color:#0000ff;">string</span>&#62;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 30:             items.Add(&#34;<span style="color:#8b0000;">Maryland</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 31:             items.Add(&#34;<span style="color:#8b0000;">California</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 32:             items.Add(&#34;<span style="color:#8b0000;">Taxes</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 33:             items.Add(&#34;<span style="color:#8b0000;">Washington</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 34:             items.Add(&#34;<span style="color:#8b0000;">Virginia</span>&#34;);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 35:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 36:             list.ItemsSource = items;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 37:         }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 38:     }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 39: }
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 40: </pre>
</pre>
<p>Here is XAML code of our project.</p>
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:450px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Window</span> <span style="color:#ff0000;">x</span>:<span style="color:#ff0000;">Class</span>=<span style="color:#0000ff;">&#34;UIElement.Window1&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  2:     <span style="color:#ff0000;">xmlns</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  3:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">x</span>=<span style="color:#0000ff;">&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  4:     <span style="color:#ff0000;">xmlns</span>:<span style="color:#ff0000;">local</span>=<span style="color:#0000ff;">&#34;clr-namespace:UIElement&#34;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  5:     <span style="color:#ff0000;">Title</span>=<span style="color:#0000ff;">&#34;ListView Example&#34;</span> <span style="color:#ff0000;">Height</span>=<span style="color:#0000ff;">&#34;300&#34;</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;400&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  6:     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  7:         <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView</span> <span style="color:#ff0000;">Name</span>=<span style="color:#0000ff;">&#34;list&#34;</span> <span style="color:#ff0000;">Margin</span>=<span style="color:#0000ff;">&#34;5&#34;</span> <span style="color:#ff0000;">HorizontalContentAlignment</span>=<span style="color:#0000ff;">&#34;Stretch&#34;</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  8:             <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;">  9:                 <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 10:                     <span style="color:#0000ff;">&#60;</span><span style="color:#800000;">GridViewColumn</span> <span style="color:#ff0000;">Width</span>=<span style="color:#0000ff;">&#34;Auto&#34;</span> <span style="color:#ff0000;">Header</span>=<span style="color:#0000ff;">&#34;States Name&#34;</span> <span style="color:#ff0000;">DisplayMemberBinding</span>=<span style="color:#0000ff;">&#34;{Binding}&#34;</span><span style="color:#0000ff;">/&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 11:                 <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">GridView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 12:             <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView.View</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 13:         <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">ListView</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 14:     <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Grid</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 15: <span style="color:#0000ff;">&#60;/</span><span style="color:#800000;">Window</span><span style="color:#0000ff;">&#62;</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,&#39;font-size:12px;margin:0;"> 16: </pre>
</pre>
<p>Here is the output of this program.</p>
<p><a href="http://zamjad.files.wordpress.com/2009/11/listviewoutput.gif"><img style="border-bottom:0;border-left:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;" title="ListViewOutput" border="0" alt="ListViewOutput" src="http://zamjad.files.wordpress.com/2009/11/listviewoutput_thumb.gif?w=400&#038;h=300" width="400" height="300" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Using the VisualStateManager with the Model-View-Viewmodel pattern in WPF or Silverlight]]></title>
<link>http://tdanemar.wordpress.com/2009/11/15/using-the-visualstatemanager-with-the-model-view-viewmodel-pattern-in-wpf-or-silverlight/</link>
<pubDate>Sun, 15 Nov 2009 17:27:11 +0000</pubDate>
<dc:creator>Thomas Danemar</dc:creator>
<guid>http://tdanemar.wordpress.com/2009/11/15/using-the-visualstatemanager-with-the-model-view-viewmodel-pattern-in-wpf-or-silverlight/</guid>
<description><![CDATA[The visual state manager is a powerful addition to WPF 4.0 that facilitates handling state visuals f]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>The <a href="http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx">visual state manager</a> is a powerful addition to WPF 4.0 that facilitates handling state visuals for WPF and Silverlight controls. For example, a button control could have the states &#8220;Pressed&#8221;, &#8220;Normal&#8221;, &#8220;Disabled&#8221;, etc., and have different looks for each of those states, with transitions between them. If you&#8217;re unfamiliar with the Visual State Manager, check out the <a href="http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx">Visual State Manager Overview</a>, or <a href="http://weblogs.asp.net/scottgu/archive/2008/06/06/silverlight-2-beta2-released.aspx">ScottGu&#8217;s post</a>.</p>
<p>The Visual State Manager is already a part of Silverlight 2, and will be in WPF 4.0. You can, however, use it already if you download the official <a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29117">WPF Toolkit</a>.</p>
<p>Now, as nice as the VisualStateManager (VSM) is, anyone who has tried to use it with the <a href="http://msdn.microsoft.com/en-us/magazine/dd419663.aspx">Model-View-Viewmodel (MVVM)</a> or <a href="http://msdn.microsoft.com/en-us/magazine/cc188690.aspx">Model-View-Presenter (MVP)</a> will have run into some issues. The big showstopper is that to change states using the VSM, you have to pass the view as an argument:</p>
<pre class="brush: csharp;">
VisualStateManager.GoToState(View, stateName, true);
</pre>
<p>If you&#8217;re using the MVP pattern, this is okay, since your presenter will likely be aware of the view. For example, if you&#8217;re using <a href="http://www.codeplex.com/caliburn">Caliburn</a> (which, by the way, is an awesome framework for MVP or MVVM), you can do something like this:</p>
<pre class="brush: csharp;">
private object View { get; set; }
public override void ViewLoaded(object view, object context)
{
	View = view;
	base.ViewLoaded(view, context);
}

private void ChangeStateTo(string stateName)
{
	Application.Current.Dispatcher.Invoke((System.Action) (delegate()
	{
		VisualStateManager.GoToState((Control)View, stateName, true);
	}), null);
}
</pre>
<p>This works just fine. But if you&#8217;re using MVVM this isn&#8217;t really a solution, since the viewmodel should not have to know about the view. Also, ideally you&#8217;d like to bind your visual state to a property on the presenter/viewmodel. Unit testing states will also be difficult like this.</p>
<p>The solution lies in WPF&#8217;s attached properties (ooh, don&#8217;t we just love those?). We&#8217;ll create a helper class with a VisualState depencency property, and in the PropertyChangedCallback method for that property we&#8217;ll pass the sender (which will be our view) and the new property value (which will be the name of the state) to the VisualStateManager:</p>
<pre class="brush: csharp;">
public class StateManager : DependencyObject
{
	public static string GetVisualStateProperty(DependencyObject obj)
	{
		return (string)obj.GetValue(VisualStatePropertyProperty);
	}

	public static void SetVisualStateProperty(DependencyObject obj, string value)
	{
		obj.SetValue(VisualStatePropertyProperty, value);
	}

	public static readonly DependencyProperty VisualStatePropertyProperty =
		DependencyProperty.RegisterAttached(
		&#34;VisualStateProperty&#34;,
		typeof(string),
		typeof(StateManager),
		new PropertyMetadata((s, e) =&#62;
		{
		var propertyName = (string)e.NewValue;
		var ctrl = s as Control;
		if (ctrl == null)
			throw new InvalidOperationException(&#34;This attached property only supports types derived from Control.&#34;);
		System.Windows.VisualStateManager.GoToState(ctrl, (string)e.NewValue, true);
	}));
}
</pre>
<p>Now in XAML we can bind the VisualStateName string property on our viewmodel to our new helper class:</p>
<pre class="brush: csharp;">
&#60;UserControl x:Class=&#34;MyApp.SomeView&#34;
//namespaces omitted for brevity
MyApp:StateManager.VisualStateProperty=&#34;{Binding VisualStateName}&#34;&#62;
</pre>
<p>And that&#8217;s it! Our helper class will switch states on the view for us. The viewmodel no longer has to be aware of the view, and unit testing states becomes a lot easier.</p>
<p>Many thanks to Rob Eisenberg, author of <a href="http://www.codeplex.com/caliburn">Caliburn</a>, and to whoever wrote <a href="http://gist.github.com/197979">this</a> piece of code on Github, for putting me on the right track.</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[WPFToolkit Calendar Control Step trough]]></title>
<link>http://codesticks.wordpress.com/2009/11/15/wpftoolkit-calendar-control-step-trough/</link>
<pubDate>Sun, 15 Nov 2009 14:07:54 +0000</pubDate>
<dc:creator>winglinglang</dc:creator>
<guid>http://codesticks.wordpress.com/2009/11/15/wpftoolkit-calendar-control-step-trough/</guid>
<description><![CDATA[In this section we will dissect the wpf toolkit calendar control. To learn more on how Microsoft cod]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>In this section we will dissect the wpf toolkit calendar control. To learn more on how Microsoft codes for wpf.</p>
<p>One of the challenges I had writing my own calendar control and some of the samples I looked at on the web was to display the day&#8217;s in the calendar control. At first it sounds easy, you use a uniform grid control with 7 columns and bind to a list of day&#8217;s, another solution was to use a list box and dived the days into weeks, then you have a week template and list box template. All very well. The problem was where do you store the list of day&#8217;s neatly away from the controls user yet make it easy to access for the data binding and flexible for new templates and styles to be applied.</p>
<p>Let see how the toolkit team did it.</p>
<h3>WPF Toolkit Calendar Control</h3>
<div id="attachment_28" class="wp-caption alignnone" style="width: 201px"><img class="size-full wp-image-28" title="Calendar" src="http://codesticks.wordpress.com/files/2009/11/calendar1.png" alt="Calendar" width="191" height="172" /><p class="wp-caption-text">WPF ToolKit Calendar Control</p></div>
<p>Lets start at the Calendar style, From the main <strong>Calendar </strong>style they have a <strong>CalendarItem.  <span style="font-weight:normal;">The <strong>CalendarItem </strong>is a WPF Control on its own, a nice future of the Toolkit Calendar is that it support multiple Views, this is all handled by the CalendarItem style. Having the Calendar Control Contain one CalendarItem is a clever way of Hiding the Control Code from the actual code the developer will want to see when consuming the control. </span></strong></p>
<p>The Toolkit CalendarItem use a Grid to display the day&#8217;s with 7 columns and 7 rows fields called &#8216;<em>PART_MonthView</em>&#8216; the grid is contained in parent grid with 2 rows and 3 Columns. The parent grid displays the left and right arrows and the heading.</p>
<h3>Filling the Days in the PART_MonthView</h3>
<p>After the Control Template is set, The C# code extracts all the Template &#8216;PARTs&#8217; and assign it too internal variables prefixed with underscore. the one we are interested in is &#8216;_monthView&#8217; which is the grid with 7 rows and 7 columns.</p>
<p>_monthView is populated with &#8216;CalendarDayButton&#8217; Controls using a standard loop. The CalendarItem Control Populates the grid via a function &#8216;PopulateGrids()&#8217;</p>
<p><strong>PopulateGrids() </strong>Sets the CalendarDayButton Owner and assign the events and binds the style property.</p>
<p><strong>private void SetMonthModeDayTitles() <span style="font-weight:normal;">Sets the Day Titles by looping trought the 1 ste 7 cells  in the Month View Grid. Then the day&#8217;s are set using the SetMonthModeCalendarDayButtons function. </span></strong></p>
<p><strong><span style="font-weight:normal;">Here is a quick view of this function.</span></strong></p>
<pre class="brush: csharp;">
private void SetMonthModeCalendarDayButtons()
{
 DateTime firstDayOfMonth = DateTimeHelper.DiscardDayTime(DisplayDate);
 int lastMonthToDisplay = GetNumberOfDisplayedDaysFromPreviousMonth(firstDayOfMonth);
 bool isMinMonth = DateTimeHelper.CompareYearMonth(firstDayOfMonth,DateTime.MinValue) &#60;= 0;
 bool isMaxMonth = DateTimeHelper.CompareYearMonth(firstDayOfMonth,DateTime.MaxValue) &#62;= 0;
 int daysInMonth =_calendar.GetDaysInMonth(firstDayOfMonth.Year, firstDayOfMonth.Month);
 int count = ROWS * COLS;

 //Loop the cell's ignoring the first seven as they contain the day names for the title.
 for (int childIndex = COLS; childIndex &#60; count; childIndex++)
 {
 CalendarDayButton childButton = _monthView.Children[childIndex] as CalendarDayButton;
 Debug.Assert(childButton !=null);
 int dayOffset = childIndex - lastMonthToDisplay- COLS;

  //Set DayButton Control with the new Content.
 if ((!isMinMonth &#124;&#124; (dayOffset &#62;= 0)) &#38;&#38;(!isMaxMonth &#124;&#124; (dayOffset &#60; daysInMonth)))
 {
 DateTime dateToAdd =_calendar.AddDays(firstDayOfMonth, dayOffset);
 //Sets and Calculates all the Properties for the Day
 SetMonthModeDayButtonState(childButton, dateToAdd);
 childButton.DataContext = dateToAdd;
 childButton.SetContentInternal(DateTimeHelper.ToDayString(dateToAdd));
 }
 else
 {
 SetMonthModeDayButtonState(childButton, null);
 childButton.DataContext = null;
 childButton.SetContentInternal(DateTimeHelper.ToDayString(null));
 }
 }
}
</pre>
<ul>
<li><span style="line-height:14px;">You Hide the complexities of the month and day calculations by wrapping the actual control by anouther more userfriendly control. This they did by wrapping CalendarItem with Calendar Control. CalendarItem is in a separate name space than the Calendar control, this hide&#8217;s the control from normal developers only intrested in the Calendar, but for more advance coding you can still access the the base control by adding the primitives names space.</span></li>
<li><span style="line-height:14px;">They do not recreate the Day Controls but rather just update the content&#8217;s.</span></li>
<li><span style="line-height:14px;">There was no magic to make this work its basic clever wpf and C# coding. What was intresting to me how much they still did in code.  When starting WPF you tend to do everything in WPF, and that is not always the correct or best way of doing things. </span></li>
</ul>
<p>You can find the complete WPF ToolKit and source code here.</p>
<p><a href="http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29117">http://wpf.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=29117</a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Silverlight Style: GlassBorderStyle]]></title>
<link>http://antonidol.wordpress.com/2009/11/15/silverlight-style-glassborderstyle/</link>
<pubDate>Sun, 15 Nov 2009 13:51:29 +0000</pubDate>
<dc:creator>antonidol</dc:creator>
<guid>http://antonidol.wordpress.com/2009/11/15/silverlight-style-glassborderstyle/</guid>
<description><![CDATA[Created a simple, but nice Glass Border for a panel in my current Silverlight 3 project. I’d like to]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p><a href="http://antonidol.files.wordpress.com/2009/11/glassborderstyle.jpg"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;margin:0 20px 0 0;" title="GlassBorderStyle" border="0" alt="GlassBorderStyle" align="left" src="http://antonidol.files.wordpress.com/2009/11/glassborderstyle_thumb.jpg?w=220&#038;h=220" width="220" height="220" /></a>Created a simple, but nice Glass Border for a panel in my current Silverlight 3 project. I’d like to share it with you…</p>
<p>&#160; </p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160; &#60;Style x:Key=&#34;GlassBorderStyle&#34; TargetType=&#34;Border&#34;&#62;    <br />&#160;&#160;&#160; &#60;Setter Property=&#34;BorderThickness&#34; Value=&#34;2&#34;/&#62;     <br />&#160;&#160;&#160; &#60;Setter Property=&#34;Padding&#34; Value=&#34;5&#34;/&#62;     <br />&#160;&#160;&#160; &#60;Setter Property=&#34;Background&#34;&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;Setter.Value&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;LinearGradientBrush EndPoint=&#34;0.75,1&#34; StartPoint=&#34;0.25,0&#34;&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#33FFFFFF&#34; Offset=&#34;0&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#C0FFFFFF&#34; Offset=&#34;0.287&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#4011322D&#34; Offset=&#34;0.683&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#33FFFFFF&#34; Offset=&#34;1&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/LinearGradientBrush&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/Setter.Value&#62;     <br />&#160;&#160;&#160; &#60;/Setter&#62;     <br />&#160;&#160;&#160; &#60;Setter Property=&#34;BorderBrush&#34;&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;Setter.Value&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;LinearGradientBrush EndPoint=&#34;0.5,1&#34; StartPoint=&#34;0.5,0&#34;&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#5811322D&#34; Offset=&#34;0&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#3EFFFFFF&#34; Offset=&#34;0.25&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#FFFFFFFF&#34; Offset=&#34;0.5&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#3EFFFFFF&#34; Offset=&#34;0.75&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;GradientStop Color=&#34;#BFFFFFFF&#34; Offset=&#34;1&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/LinearGradientBrush&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/Setter.Value&#62;     <br />&#160;&#160;&#160; &#60;/Setter&#62;     <br />&#160;&#160;&#160; &#60;Setter Property=&#34;Effect&#34;&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;Setter.Value&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;DropShadowEffect BlurRadius=&#34;3&#34; ShadowDepth=&#34;3&#34; Opacity=&#34;0.5&#34;/&#62;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &#60;/Setter.Value&#62;     <br />&#160;&#160;&#160; &#60;/Setter&#62;     <br />&#60;/Style&#62;</p>
<p> To use this style:</p>
<p> &#60;Border x:Name=&#34;GlassBorder&#34; Height=&#34;100&#34; Width=&#34;100&#34; CornerRadius=&#34;10&#34;   <br />&#160;&#160;&#160; Style=&#34;{StaticResource GlassBorderStyle}&#34;&#62;     <br />&#160;&#160;&#160; &#60;Button Content=&#34;OK&#34;/&#62;     <br />&#60;/Border&#62;</p>
<p> Njoy!</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[&ldquo;Boxmarking&rdquo; in Visual Studio 2010]]></title>
<link>http://fragiledevelopment.wordpress.com/2009/11/14/boxmarking-in-visual-studio-2010/</link>
<pubDate>Sat, 14 Nov 2009 22:10:48 +0000</pubDate>
<dc:creator>Viktor Larsson</dc:creator>
<guid>http://fragiledevelopment.wordpress.com/2009/11/14/boxmarking-in-visual-studio-2010/</guid>
<description><![CDATA[I’ve been trying out the Visual Studio 2010 beta for a week now and I love it. One of my favorite fe]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I’ve been trying out the Visual Studio 2010 beta for a week now and I love it. One of my favorite features is the boxmarking which VS now allows. This is nothing new but is incredibly useful when editing code.</p>
<p>In my sideproject, the Imageboard-Viewer, I wanted to apply a Style template to a list of ComboBoxItems<strong>.</strong> In Visual Studio 2008, I’d been forced to copy paste the text and change rows a million times (there are more items than visible here, although maybe not a million) .</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image1.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border:0;" title="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb1.png?w=190&#038;h=159" border="0" alt="image" width="190" height="159" /></a>What I did instead was hold down <strong>Alt </strong>while dragging a thin vertical box and pasting my code once. This resulted in the same text being pasted to each row.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image2.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border:0;" title="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb2.png?w=422&#038;h=213" border="0" alt="image" width="422" height="213" /></a></p>
<p>I also got a chance to use boxmarking when copying multiple values. I wanted to set the content of the ComboBoxItems according to names. As is visible in the above picture, I had several different values to copy.</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image3.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border:0;" title="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb3.png?w=446&#038;h=165" border="0" alt="image" width="446" height="165" /></a> Boxmarking makes this an easy and quick task to complete. Imagine the time saving possibilities when handling hundreds of rows at the same time.</p>
<p>Now I just write the word <strong>Content </strong>and paste my names</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image4.png"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border:0;" title="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb4.png?w=437&#038;h=131" border="0" alt="image" width="437" height="131" /></a></p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[GraySky Button (WPF Style)]]></title>
<link>http://vladeck.wordpress.com/2009/11/14/graysky-button-wpf-style/</link>
<pubDate>Sat, 14 Nov 2009 15:12:07 +0000</pubDate>
<dc:creator>vladeck</dc:creator>
<guid>http://vladeck.wordpress.com/2009/11/14/graysky-button-wpf-style/</guid>
<description><![CDATA[I present you the first style (of many to come) for your projects: GraySky Button style. It is based]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I present you the first style (of many to come) for your projects: GraySky Button style. It is based on screenshots from Shiki-Colors GTK+ themes (no original source is used, just a lot of screenshots and color picking).</p>
<p><a href="http://vladeck.wordpress.com/files/2009/11/graysky_button_preview.png"><img class="alignnone size-full wp-image-54" title="GraySky_Button_Preview" src="http://vladeck.wordpress.com/files/2009/11/graysky_button_preview.png" alt="GraySky_Button_Preview" width="91" height="122" /></a></p>
<p>I&#8217;ve provided ResourceDictionary that you can use. Download <a href="http://vladeck.wordpress.com/files/2009/11/grayskybutton.doc">here</a> (rename .DOC to .RAR &#8211; wordpress limitation).</p>
</div>]]></content:encoded>
</item>
<item>
<title><![CDATA[Custom control in WPF / Silverlight with XAML]]></title>
<link>http://fragiledevelopment.wordpress.com/2009/11/14/custom-control-in-wpf-silverlight-with-xaml/</link>
<pubDate>Sat, 14 Nov 2009 08:49:50 +0000</pubDate>
<dc:creator>Viktor Larsson</dc:creator>
<guid>http://fragiledevelopment.wordpress.com/2009/11/14/custom-control-in-wpf-silverlight-with-xaml/</guid>
<description><![CDATA[I’m currently working on a little side-project in WPF. A sort of imageviewer for imageboards. Since ]]></description>
<content:encoded><![CDATA[<div class='snap_preview'><p>I’m currently working on a little side-project in WPF. A sort of imageviewer for imageboards. Since I want as much windowspace as possible for the images, I decided to put some of my icons on top of the image thumbnails. This proved hard to do. I therefore made a <strong>Custom Class</strong> called “MainImage”. This class will display both the original image (named here <em>BackgroundImage</em>) and two icons which I later added eventhandlers to to capture clicks. This worked out wonderfully well. The result is something like this:</p>
<p><a href="http://fragiledevelopment.files.wordpress.com/2009/11/image.png"><img style="border-bottom:0;border-left:0;display:inline;border-top:0;border-right:0;" title="image" border="0" alt="image" src="http://fragiledevelopment.files.wordpress.com/2009/11/image_thumb.png?w=439&#038;h=96" width="439" height="96" /></a></p>
<p>First two normal images are put into my WrapPanel, then the third is my custom MainImage. Notice how it looks similar to the first two images but with the added icons on it. These icons are linked to two different event handlers in my codebehind. And thanks to my custom class, I can generate these custom images dynamically in my codebehind.</p>
<p><strong>Tip:</strong> If you name your elements in a custom class (as I named my <em>BackgroundImage</em> ), you can set them and their properties in the codebehind just like any other property. </p>
<p><strong>HowTo: </strong>To create a customclass, just rightclick your project in the Solution Explorer, choose “<em>Add User Control” </em>and choose a name for your control. You will now have a new item called <em>YourName.xaml </em>which in turn has a .cs file associated with it. </p>
<p>Here is the code I used for my MainImage control. </p>
<div style="font-family:courier new;background:white;color:black;font-size:6pt;">
<p style="margin:0;"><span style="color:blue;">&#60;</span><span style="color:#a31515;">UserControl</span><span style="color:red;"> x</span><span style="color:blue;">:</span><span style="color:red;">Class</span><span style="color:blue;">=&#34;MyProject.MainImage&#34;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:red;">xmlns</span><span style="color:blue;">=&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">x</span><span style="color:blue;">=&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34;</span></p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">mc</span><span style="color:blue;">=&#34;http://schemas.openxmlformats.org/markup-compatibility/2006&#34;</span> </p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:red;">xmlns</span><span style="color:blue;">:</span><span style="color:red;">d</span><span style="color:blue;">=&#34;http://schemas.microsoft.com/expression/blend/2008&#34;</span> </p>
<p style="margin:0;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; <span style="color:red;">mc</span><span style="color:blue;">:</span><span style="color:red;">Ignorable</span><span style="color:blue;">=&#34;d&#34;</span><span style="color:red;"> d</span><span style="color:blue;">:</span><span style="color:red;">DesignHeight</span><span style="color:blue;">=&#34;200&#34;</span><span style="color:red;"> d</span><span style="color:blue;">:</span><span style="color:red;">DesignWidth</span><span style="color:blue;">=&#34;200&#34;&#62;</span></p>
<p style="margin:0;">&#160;</p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">Grid.RowDefinitions</span><span style="color:blue;">&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">RowDefinition</span><span style="color:red;"> Height</span><span style="color:blue;">=&#34;2*&#34; /&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">RowDefinition</span><span style="color:red;"> Height</span><span style="color:blue;">=&#34;1*&#34; /&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;/</span><span style="color:#a31515;">Grid.RowDefinitions</span><span style="color:blue;">&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">Grid.ColumnDefinitions</span><span style="color:blue;">&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">ColumnDefinition</span><span style="color:red;"> Width</span><span style="color:blue;">=&#34;*&#34;/&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">ColumnDefinition</span><span style="color:red;"> Width</span><span style="color:blue;">=&#34;*&#34;/&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">ColumnDefinition</span><span style="color:red;"> Width</span><span style="color:blue;">=&#34;*&#34;/&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;/</span><span style="color:#a31515;">Grid.ColumnDefinitions</span><span style="color:blue;">&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">Image</span><span style="color:red;"> Name</span><span style="color:blue;">=&#34;BackgroundImage&#34;</span><span style="color:red;"> Grid.Column</span><span style="color:blue;">=&#34;0&#34;</span><span style="color:red;"> Grid.Row</span><span style="color:blue;">=&#34;0&#34;</span><span style="color:red;"> Grid.RowSpan</span><span style="color:blue;">=&#34;2&#34;</span><span style="color:red;"> Grid.ColumnSpan</span><span style="color:blue;">=&#34;3&#34; /&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">Image</span><span style="color:red;"> Name</span><span style="color:blue;">=&#34;ThreadImage&#34;</span><span style="color:red;"> Source</span><span style="color:blue;">=&#34;Images/icon.png&#34;</span><span style="color:red;"> Grid.Column</span><span style="color:blue;">=&#34;0&#34;</span><span style="color:red;"> Grid.Row</span><span style="color:blue;">=&#34;1&#34;</span><span style="color:red;"> Height</span><span style="color:blue;">=&#34;15&#34;</span><span style="color:red;"> Width</span><span style="color:blue;">=&#34;15&#34;</span><span style="color:blue;"> /&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color:blue;">&#60;</span><span style="color:#a31515;">Image</span><span style="color:red;"> Name</span><span style="color:blue;">=&#34;BrowserImage&#34;</span><span style="color:red;"> Source</span><span style="color:blue;">=&#34;Images/icon.png&#34;</span><span style="color:red;"> Grid.Column</span><span style="color:blue;">=&#34;1&#34;</span><span style="color:red;"> Grid.Row</span><span style="color:blue;">=&#34;1&#34;</span><span style="color:red;"> Height</span><span style="color:blue;">=&#34;15&#34;</span><span style="color:red;"> Width</span><span style="color:blue;">=&#34;15&#34; /&#62;</span></p>
<p style="margin:0;"><span style="color:#a31515;">&#160;&#160;&#160; </span><span style="color:blue;">&#60;/</span><span style="color:#a31515;">Grid</span><span style="color:blue;">&#62;</span></p>
<p style="margin:0;"><span style="color:blue;">&#60;/</span><span style="color:#a31515;">UserControl</span><span style="color:blue;">&#62;</span></p>
</p></div>
</div>]]></content:encoded>
</item>

</channel>
</rss>
