<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>TDD developer &#187; Databinding</title>
	<atom:link href="http://testdrivendevelopment.wordpress.com/tag/databinding/feed/" rel="self" type="application/rss+xml" />
	<link>http://testdrivendevelopment.wordpress.com</link>
	<description>Diary of an agile developer</description>
	<lastBuildDate>Wed, 28 Oct 2009 22:06:05 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='testdrivendevelopment.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://www.gravatar.com/blavatar/a6ef45b2d30fa0fcbe697fa111d46fdd?s=96&#038;d=http://s.wordpress.com/i/buttonw-com.png</url>
		<title>TDD developer &#187; Databinding</title>
		<link>http://testdrivendevelopment.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://testdrivendevelopment.wordpress.com/osd.xml" title="TDD developer" />
		<item>
		<title>Databinding WPF treeview using recursion</title>
		<link>http://testdrivendevelopment.wordpress.com/2008/07/15/databinding-wpf-treeview-using-recursion/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2008/07/15/databinding-wpf-treeview-using-recursion/#comments</comments>
		<pubDate>Tue, 15 Jul 2008 21:54:57 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Databinding]]></category>
		<category><![CDATA[treeview]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2008/07/15/databinding-wpf-treeview-using-recursion/</guid>
		<description><![CDATA[Today I solved a very interesting problem using a TreeView and a HierarchicalDataTemplate. My final goal was to display an objects tree using a TreeView control as shown here below.
 
The result is not very nice but wait, I am a developer not a designer!Ok, less chatter! Let&#8217;s look at the code that is much [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=39&subd=testdrivendevelopment&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>Today I solved a very interesting problem using a TreeView and a HierarchicalDataTemplate. My final goal was to display an objects tree using a TreeView control as shown here below.</p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2008/07/image.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="157" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2008/07/image-thumb.png?w=244&#038;h=157" width="244" border="0"></a> </p>
<p>The result is not very nice but wait, I am a developer not a designer!<br />Ok, less chatter! Let&#8217;s look at the code that is much more interesting. <br />In this case the datasource is a tree composed by a set of Foo objects.<br />Here is the Foo class definition</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Foo
{
    <span class="kwrd">public</span> Foo()
    {
        Children = <span class="kwrd">new</span> List&lt;Foo&gt;();
    }
    <span class="kwrd">public</span> <span class="kwrd">int</span> Id { get; set; }
    <span class="kwrd">public</span> <span class="kwrd">string</span> Name { get; set; }
    <span class="kwrd">public</span> IList&lt;Foo&gt; Children { get; set; }
}</pre>
<p>and here a dummy method that create a sample objects tree</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">class</span> Service
{
    <span class="kwrd">private</span> <span class="kwrd">readonly</span> Collection&lt;Foo&gt; fooList;

    <span class="kwrd">public</span> IEnumerable&lt;Foo&gt; FooList
    {
        get { <span class="kwrd">return</span> fooList; }
    }

    <span class="kwrd">public</span> Service()
    {
        fooList = <span class="kwrd">new</span> Collection&lt;Foo&gt; { <span class="kwrd">new</span> Foo { Id = 0, Name = <span class="str">"first"</span> }, <span class="kwrd">new</span> Foo { Id = 99, Name = <span class="str">"makka"</span> } };
        fooList[0].Children.Add(<span class="kwrd">new</span> Foo { Id = 1, Name = <span class="str">"second"</span> });
        fooList[0].Children.Add(<span class="kwrd">new</span> Foo { Id = 2, Name = <span class="str">"third"</span> });
        fooList[0].Children[0].Children.Add(<span class="kwrd">new</span> Foo { Id = 3, Name = <span class="str">"fourth"</span> });
    }
}</pre>
<p>Until here nothing special.<br />The interesting part is the XAML markup. As you can see using the power of HierarchicalDataTemplate with few lines of code we can create a recursive loop in order to populate the TreeView starting from a simple IEnumerable&lt;Foo&gt; object</p>
<pre class="csharpcode"><span class="kwrd">&lt;</span><span class="html">TreeView</span> <span class="attr">Name</span><span class="kwrd">="viewsTreeView"</span>  <span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;</span><span class="html">TreeView.Resources</span><span class="kwrd">&gt;</span>
        <span class="kwrd">&lt;</span><span class="html">HierarchicalDataTemplate</span> <span class="attr">DataType</span><span class="kwrd">="{x:Type Demo:Foo}"</span> <span class="attr">ItemsSource</span><span class="kwrd">="{Binding Path=Children}"</span><span class="kwrd">&gt;</span>
            <span class="kwrd">&lt;</span><span class="html">TreeViewItem</span> <span class="attr">Header</span><span class="kwrd">="{Binding Path=Name}"</span>  <span class="kwrd">/&gt;</span>
        <span class="kwrd">&lt;/</span><span class="html">HierarchicalDataTemplate</span><span class="kwrd">&gt;</span>
    <span class="kwrd">&lt;/</span><span class="html">TreeView.Resources</span><span class="kwrd">&gt;</span>
<span class="kwrd">&lt;/</span><span class="html">TreeView</span><span class="kwrd">&gt;</span></pre>
<p>I hope this sample will save you some time!</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:1743d044-8649-4764-8ba4-677b4b683be7" style="display:inline;margin:0;padding:0;">Technorati Tag: <a href="http://technorati.com/tags/databinding" rel="tag">databinding</a>,<a href="http://technorati.com/tags/WPF" rel="tag">WPF</a>,<a href="http://technorati.com/tags/treeview" rel="tag">treeview</a>,<a href="http://technorati.com/tags/recursive" rel="tag">recursive</a></div>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/testdrivendevelopment.wordpress.com/39/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/testdrivendevelopment.wordpress.com/39/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=39&subd=testdrivendevelopment&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2008/07/15/databinding-wpf-treeview-using-recursion/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2008/07/image-thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
		<item>
		<title>When WPF Databinding change the way you write code</title>
		<link>http://testdrivendevelopment.wordpress.com/2008/05/21/when-wpf-databinding-change-the-way-you-write-code/</link>
		<comments>http://testdrivendevelopment.wordpress.com/2008/05/21/when-wpf-databinding-change-the-way-you-write-code/#comments</comments>
		<pubDate>Wed, 21 May 2008 07:58:01 +0000</pubDate>
		<dc:creator>makka</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Databinding]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://testdrivendevelopment.wordpress.com/2008/05/21/when-wpf-databinding-change-the-way-you-write-code/</guid>
		<description><![CDATA[In these days I&#8217;m developing my first real production project with WPF and one of main different with Windows Form is Databinding. In WPF, databinding is very powerfull and sometimes allow you to write markup code that replace procedural code normaly used in Windows Form. 
For example in this little piece of code I have [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=26&subd=testdrivendevelopment&ref=&feed=1" />]]></description>
			<content:encoded><![CDATA[<div class='snap_preview'><br /><p>In these days I&#8217;m developing my first real production project with WPF and one of main different with Windows Form is Databinding. In WPF, databinding is very powerfull and sometimes allow you to write markup code that replace procedural code normaly used in Windows Form. </p>
<p>For example in this little piece of code I have written today use Databinding &amp; Converter </p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2008/05/image.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="282" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2008/05/image-thumb.png?w=548&#038;h=282" width="548" border="0"></a> </p>
<p>in order to change StatusBar Visiblity when IsChecked property change on Checkbox </p>
<p><a href="http://testdrivendevelopment.files.wordpress.com/2008/05/image1.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="89" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2008/05/image-thumb1.png?w=244&#038;h=89" width="244" border="0"></a> <a href="http://testdrivendevelopment.files.wordpress.com/2008/05/image2.png"><img style="border-right:0;border-top:0;border-left:0;border-bottom:0;" height="91" alt="image" src="http://testdrivendevelopment.files.wordpress.com/2008/05/image-thumb2.png?w=244&#038;h=91" width="244" border="0"></a> </p>
<p>The syntax is very compact and it&#8217;s very powerfull doing this things whit XAML markup but I&#8217;m wondering how to test this behaviour.</p>
<p>I thing in another post I will cover this topic.</p>
<p>&nbsp;</p>
<div class="wlWriterSmartContent" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:7be8c38c-58ae-442d-b264-5917ebefdea2" style="display:inline;margin:0;padding:0;">Technorati Tag: <a href="http://technorati.com/tags/wpf" rel="tag">wpf</a>,<a href="http://technorati.com/tags/databinding" rel="tag">databinding</a>,<a href="http://technorati.com/tags/converter" rel="tag">converter</a></div>
<img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/testdrivendevelopment.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/testdrivendevelopment.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/testdrivendevelopment.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/testdrivendevelopment.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/testdrivendevelopment.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/testdrivendevelopment.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/testdrivendevelopment.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/testdrivendevelopment.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/testdrivendevelopment.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/testdrivendevelopment.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/testdrivendevelopment.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/testdrivendevelopment.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=testdrivendevelopment.wordpress.com&blog=2459763&post=26&subd=testdrivendevelopment&ref=&feed=1" /></div>]]></content:encoded>
			<wfw:commentRss>http://testdrivendevelopment.wordpress.com/2008/05/21/when-wpf-databinding-change-the-way-you-write-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/eaac7e727c1e026a9677bf418eca3ee9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">makka</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2008/05/image-thumb.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2008/05/image-thumb1.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>

		<media:content url="http://testdrivendevelopment.files.wordpress.com/2008/05/image-thumb2.png" medium="image">
			<media:title type="html">image</media:title>
		</media:content>
	</item>
	</channel>
</rss>