<?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>Jann's Blog</title>
	<atom:link href="http://jannsblog.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://jannsblog.wordpress.com</link>
	<description>WPF, C# and LINQ</description>
	<lastBuildDate>Thu, 16 Apr 2009 16:14:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='jannsblog.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Jann's Blog</title>
		<link>http://jannsblog.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://jannsblog.wordpress.com/osd.xml" title="Jann&#039;s Blog" />
	<atom:link rel='hub' href='http://jannsblog.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Text-To-Speech Button</title>
		<link>http://jannsblog.wordpress.com/2009/04/16/text-to-speech-button/</link>
		<comments>http://jannsblog.wordpress.com/2009/04/16/text-to-speech-button/#comments</comments>
		<pubDate>Thu, 16 Apr 2009 16:03:45 +0000</pubDate>
		<dc:creator>Jann</dc:creator>
				<category><![CDATA[.Net]]></category>
		<category><![CDATA[.net-Framework]]></category>
		<category><![CDATA[c#]]></category>

		<guid isPermaLink="false">http://jannsblog.wordpress.com/?p=31</guid>
		<description><![CDATA[Recently, I stumbled upon the System.Speech.Synthesis namespace. It is located in the System.Speech.dll that comes with the .Net-Framework – for free! It offers a convenient way to read text to the user. Take this button as an example: public class TTSButton: Button { #region Text &#160; /// &#60;summary&#62; /// This is the text that should [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jannsblog.wordpress.com&amp;blog=6808952&amp;post=31&amp;subd=jannsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Recently, I stumbled upon the <strong>System.Speech.Synthesis</strong> namespace. It is located in the System.Speech.dll that comes with the .Net-Framework – for free! It offers a convenient way to read text to the user. Take this button as an example:</p>
<div style="border-bottom:gray 1px solid;border-left:gray 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:consolas, &#39;max-height:200px;font-size:8pt;overflow:auto;border-top:gray 1px solid;cursor:text;border-right:gray 1px solid;margin:20px 0 10px;padding:4px;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;">
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> TTSButton: Button</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">{</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#cc6633;">#region</span> Text</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// &lt;summary&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// This is the text that should be read when the button is clicked</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// &lt;/summary&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> TextToRead</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        get { <span style="color:#0000ff;">return</span> (<span style="color:#0000ff;">string</span>)GetValue(TextToReadProperty); }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        set { SetValue(TextToReadProperty, <span style="color:#0000ff;">value</span>); }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">static</span> <span style="color:#0000ff;">readonly</span> DependencyProperty TextToReadProperty =</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        DependencyProperty.Register(<span style="color:#006080;">&quot;TextToRead&quot;</span>, <span style="color:#0000ff;">typeof</span>(<span style="color:#0000ff;">string</span>), <span style="color:#0000ff;">typeof</span>(TTSButton), <span style="color:#0000ff;">new</span> UIPropertyMetadata());</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#cc6633;">#endregion</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">public</span> TTSButton()</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        : <span style="color:#0000ff;">base</span>()</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">this</span>.Click += <span style="color:#0000ff;">new</span> RoutedEventHandler(TTSButton_Click);</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">&#160;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// &lt;summary&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// Read the text to the user</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// &lt;/summary&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// &lt;param name=&quot;sender&quot;&gt;The sender&lt;/param&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#008000;">/// &lt;param name=&quot;e&quot;&gt;The event&lt;/param&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    <span style="color:#0000ff;">void</span> TTSButton_Click(<span style="color:#0000ff;">object</span> sender, RoutedEventArgs e)</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    {</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        <span style="color:#0000ff;">if</span> (String.IsNullOrEmpty(<span style="color:#0000ff;">this</span>.TextToRead))</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">            <span style="color:#0000ff;">return</span>;</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        SpeechSynthesizer s = <span style="color:#0000ff;">new</span> SpeechSynthesizer();</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">        s.SpeakAsync(<span style="color:#0000ff;">this</span>.TextToRead);</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">    }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;font-family:consolas, &#39;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;">}</pre>
</p>
</div>
</div>
<p>The button gets its text from a dependency which enables binding, etc. The actual reading is done in just two lines of code! However, it is possible to customize the voice, e.g. by changing the speaker or the pace.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jannsblog.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jannsblog.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jannsblog.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jannsblog.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jannsblog.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jannsblog.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jannsblog.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jannsblog.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jannsblog.wordpress.com&amp;blog=6808952&amp;post=31&amp;subd=jannsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jannsblog.wordpress.com/2009/04/16/text-to-speech-button/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/994fef3da8fd414db6834e3a758097b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jannmueller</media:title>
		</media:content>
	</item>
		<item>
		<title>Serializing an Object Tree</title>
		<link>http://jannsblog.wordpress.com/2009/03/19/serializing-an-object-tree/</link>
		<comments>http://jannsblog.wordpress.com/2009/03/19/serializing-an-object-tree/#comments</comments>
		<pubDate>Thu, 19 Mar 2009 20:16:37 +0000</pubDate>
		<dc:creator>Jann</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[serialization]]></category>
		<category><![CDATA[xaml]]></category>

		<guid isPermaLink="false">http://jannsblog.wordpress.com/?p=24</guid>
		<description><![CDATA[If you look at it closely, XAML is actually just a language that describes how to instantiate objects. Only that in most of the cases it is used to describe objects from the System.Windows.Controls namespace. When a project contains a .xaml-file, the compiler compiles it into a binary format called BAML (hard to guess &#8211; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jannsblog.wordpress.com&amp;blog=6808952&amp;post=24&amp;subd=jannsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you look at it closely, XAML is actually just a language that describes how to instantiate objects. Only that in most of the cases it is used to describe objects from the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.aspx" target="_blank">System.Windows.Controls</a> namespace. When a project contains a .xaml-file, the compiler compiles it into a binary format called BAML (hard to guess &#8211; Binary XAML). The .xaml doesn’t directly go into the assembly file, it’s the BAML file that does.</p>
<p>Even if you can’t produce BAML manually, it is possible to leverage some of the XAML-infrastructure’s power for your own purposes: With the <a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.xamlreader.aspx" target="_blank">XamlReader</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.xamlwriter.aspx" target="_blank">XamlWriter</a> classes (both are located in the <a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.aspx" target="_blank">System.Windows.Markup</a> namespace), you can serialize an arbitrary object tree into any stream (or even a string). The XamlWriter offers a single static method that basically takes an object and serializes it by serializing all of its properties. If a property has a type like string or double, the string representation of its value becomes an attribute of the xml-node. If the property is a complex object itself, it is serialized just like the first object: By analyzing all of its properties.</p>
<p>Since there is no way of passing arguments to functions in XAML, all of the serialized objects must be objects of types that have a parameterless constructor.</p>
<p><span id="more-24"></span></p>
<h2>Collections</h2>
<p>The XamlWriter recognizes collections serializes each object of the collection individually, making it a child element of the collection. The only caveat is to avoid generic collections, since they are not supported by XAML (even if a Collection&lt;String&gt; is resolved to something that looks like a Collection1[`String] at runtime). So if you want a collection to be serialized, you have to inherit from the Collection&lt;TEntity&gt; base class or any other class that implements the <a href="http://msdn.microsoft.com/en-us/library/5y536ey6.aspx" target="_blank">IList&lt;T&gt;</a> interface.</p>
<div style="border-left:1px solid gray;border-bottom:1px solid gray;line-height:12pt;background-color:#f4f4f4;width:97.5%;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;">
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> Person</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   2:</span> {</pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   3:</span>     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">string</span> Name { get; set; }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   4:</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   5:</span>     <span style="color:#0000ff;">public</span> DateTime Birthday { get; set; }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   6:</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   7:</span>     <span style="color:#0000ff;">public</span> PersonCollection Children { get; set; }</pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   8:</span> }</pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   9:</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">  10:</span> <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">class</span> PersonCollection : Collection&lt;Person&gt;</pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">  11:</span> {}</pre>
</div>
</div>
<p>A serialized instance of the Person class, obtained using the XamlWriter.Save() method, might look like this:</p>
<div style="border-left:1px solid gray;border-bottom:1px solid gray;line-height:12pt;background-color:#f4f4f4;width:97.5%;">
<div style="line-height:12pt;background-color:#f4f4f4;width:100%;">
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   1:</span> <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Person</span> <span style="color:#ff0000;">Name</span><span style="color:#0000ff;">="Franz Joseph I."</span> <span style="color:#ff0000;">Birthday</span><span style="color:#0000ff;">="1830-08-18"</span> <span style="color:#ff0000;">xmlns</span><span style="color:#0000ff;">="clr-namespace:XamlWriterSample.Persons;assembly=XamlWriterSample"</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   2:</span>     <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Person.Children</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   3:</span>         <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Person</span> <span style="color:#ff0000;">Name</span><span style="color:#0000ff;">="Sophie Frederike"</span> <span style="color:#ff0000;">Birthday</span><span style="color:#0000ff;">="1855-03-05"</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   4:</span>             <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Person.Children</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   5:</span>                 <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">PersonCollection</span> <span style="color:#0000ff;">/&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   6:</span>             <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Person.Children</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   7:</span>         <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Person</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">   8:</span>         <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Person</span> <span style="color:#ff0000;">Name</span><span style="color:#0000ff;">="Gisela Louise Marie"</span> <span style="color:#ff0000;">Birthday</span><span style="color:#0000ff;">="1856-07-12"</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">   9:</span>             <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">Person.Children</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">  10:</span>                 <span style="color:#0000ff;">&lt;</span><span style="color:#800000;">PersonCollection</span> <span style="color:#0000ff;">/&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">  11:</span>             <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Person.Children</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">  12:</span>         <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Person</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:white;width:100%;"><span style="color:#606060;">  13:</span>     <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Person.Children</span><span style="color:#0000ff;">&gt;</span></pre>
<pre style="line-height:12pt;background-color:#f4f4f4;width:100%;"><span style="color:#606060;">  14:</span> <span style="color:#0000ff;">&lt;/</span><span style="color:#800000;">Person</span><span style="color:#0000ff;">&gt;</span></pre>
</div>
</div>
<p>The xaml-Writer includes the root namespace and the assembly in the xmlns-attribute. It also references other namespaces if necessary.</p>
<h2>The Content Property</h2>
<p>If you decorate your class with the <a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.contentpropertyattribute.aspx" target="_blank">ContentProperty</a> attribute, you can declare a property to be the default content property. That way, if you write your own object tree in xaml and you add a child node to your object, it is treated as a value for the content property. This property is not actually used by the XamlWriter class.</p>
<p>It is also possible to add the <a href="http://msdn.microsoft.com/en-us/library/system.windows.markup.ambientattribute.aspx" target="_blank">AmbientAttribute</a> to one or more properties. If a property is declared ambient, its value will be applied to all properties of child objects with the same property if it is declared ambient as well. It is important do add the AmbientAttribute to both parent and child classes so that the XamlReader can set up an ambience transaction when it instantiates the objects.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jannsblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jannsblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jannsblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jannsblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jannsblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jannsblog.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jannsblog.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jannsblog.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jannsblog.wordpress.com&amp;blog=6808952&amp;post=24&amp;subd=jannsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jannsblog.wordpress.com/2009/03/19/serializing-an-object-tree/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/994fef3da8fd414db6834e3a758097b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jannmueller</media:title>
		</media:content>
	</item>
		<item>
		<title>Copy a ListView’s Items to the Clipboard</title>
		<link>http://jannsblog.wordpress.com/2009/03/10/copy-a-listview%e2%80%99s-items-to-the-clipboard/</link>
		<comments>http://jannsblog.wordpress.com/2009/03/10/copy-a-listview%e2%80%99s-items-to-the-clipboard/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 09:00:02 +0000</pubDate>
		<dc:creator>Jann</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[attached property]]></category>
		<category><![CDATA[listView]]></category>

		<guid isPermaLink="false">http://jannsblog.wordpress.com/?p=14</guid>
		<description><![CDATA[How can you copy the selected rows of a ListView to the clipboard? With the use of attached properties, this is an easy task that doesn’t require any custom controls or code-behind files. Here’s how:<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jannsblog.wordpress.com&amp;blog=6808952&amp;post=14&amp;subd=jannsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div class="mceTemp mceIEcenter" style="text-align:left;">How can you copy the selected rows of a ListView to the clipboard? With the use of attached properties, this is an easy task that doesn’t require any custom controls or code-behind files. Here’s how:</div>
<div id="attachment_8" class="wp-caption aligncenter" style="width: 554px"><img class="size-full wp-image-8" title="listviewxaml.png" src="http://jannsblog.files.wordpress.com/2009/03/listviewxaml.png?w=544&#038;h=314" alt="The XAML" width="544" height="314" /><p class="wp-caption-text">The XAML</p></div>
<p><span id="more-14"></span>First we need to extract the selected items from the ListView. This can be done by iterating over the SelectedItems collection and applying the bindings, which we can find in the Columns collection, to each object. That allows us to use format strings and converters which have been declared in the XAML. For each selected item, we append a line to the result.</p>
<div id="attachment_10" class="wp-caption aligncenter" style="width: 360px"><img class="size-full wp-image-10" title="csvsample1.png" src="http://jannsblog.files.wordpress.com/2009/03/csvsample1.png?w=350&#038;h=300" alt="csvsample1.png" width="350" height="300" /><p class="wp-caption-text">Click the button or press ctrl+c</p></div>
<p style="text-align:center;">
<p>Then we need to wrap this in an attached property. This approach is similar to what Michael Brown used to <a href="http://mbrownchicago.spaces.live.com/Blog/cns!2221DC39E0C749A4!331.entry">sort a grid</a>. When the attached property is registered, we add a command binding for the copy-command to the listview’s command bindings.</p>
<div id="attachment_12" class="wp-caption aligncenter" style="width: 480px"><img class="size-full wp-image-12" title="csvsample2.png" src="http://jannsblog.files.wordpress.com/2009/03/csvsample2.png?w=470&#038;h=91" alt="Result, pasted from the clipboard" width="470" height="91" /><p class="wp-caption-text">Result, pasted from the clipboard</p></div>
<p>When the command is executed, we just call the extension method on the listview and copy the result to the clipboard. There are three more attached properties you can use to set the delimiter, the quotation marks and whether or not to include the headers in the output.</p>
<p><a href="http://jannsblog.wordpress.com/?attachment_id=7">Sourcecode</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/jannsblog.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/jannsblog.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/jannsblog.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/jannsblog.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/jannsblog.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/jannsblog.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/jannsblog.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/jannsblog.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=jannsblog.wordpress.com&amp;blog=6808952&amp;post=14&amp;subd=jannsblog&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://jannsblog.wordpress.com/2009/03/10/copy-a-listview%e2%80%99s-items-to-the-clipboard/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/994fef3da8fd414db6834e3a758097b3?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">jannmueller</media:title>
		</media:content>

		<media:content url="http://jannsblog.files.wordpress.com/2009/03/listviewxaml.png" medium="image">
			<media:title type="html">listviewxaml.png</media:title>
		</media:content>

		<media:content url="http://jannsblog.files.wordpress.com/2009/03/csvsample1.png" medium="image">
			<media:title type="html">csvsample1.png</media:title>
		</media:content>

		<media:content url="http://jannsblog.files.wordpress.com/2009/03/csvsample2.png" medium="image">
			<media:title type="html">csvsample2.png</media:title>
		</media:content>
	</item>
	</channel>
</rss>
