<?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>Niezgod's Weblog</title>
	<atom:link href="http://niezgod.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://niezgod.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 30 Nov 2010 13:58:16 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='niezgod.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Niezgod's Weblog</title>
		<link>http://niezgod.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://niezgod.wordpress.com/osd.xml" title="Niezgod&#039;s Weblog" />
	<atom:link rel='hub' href='http://niezgod.wordpress.com/?pushpress=hub'/>
		<item>
		<title>C++ : Convertion operators</title>
		<link>http://niezgod.wordpress.com/2010/09/24/c-convertion-operators/</link>
		<comments>http://niezgod.wordpress.com/2010/09/24/c-convertion-operators/#comments</comments>
		<pubDate>Fri, 24 Sep 2010 09:36:45 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2010/09/24/c-convertion-operators</guid>
		<description><![CDATA[1: #include &#60;iostream&#62; 2: 3: class Test 4: &#123; 5: public: 6: // convertion from char const * 7: Test( const char * _rhs ) 8: : _string( _rhs ) 9: &#123;&#125; 10: 11: // convertion to char const * 12: operator char const * () 13: &#123; 14: return _string; 15: &#125; 16: 17: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=25&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!187" class="bvMsg">
<pre style="border-bottom:#cecece 1px solid;border-left:#cecece 1px solid;background-color:#fbfbfb;min-height:40px;width:650px;overflow:auto;border-top:#cecece 1px solid;border-right:#cecece 1px solid;padding:5px;">
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: #include &lt;iostream&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">class</span> Test
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4: &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">public</span>:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6: 	<span style="color:#008000;">// convertion from char const *</span>
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7: 	Test( <span style="color:#0000ff;">const</span> <span style="color:#0000ff;">char</span> * _rhs )
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8: 		: _string( _rhs )
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9: 	&#123;&#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11: 	<span style="color:#008000;">// convertion to char const *</span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12: 	<span style="color:#0000ff;">operator</span> <span style="color:#0000ff;">char</span> <span style="color:#0000ff;">const</span> * ()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13: 	&#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 14: 		<span style="color:#0000ff;">return</span> _string;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 15: 	&#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 16:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 17: <span style="color:#0000ff;">private</span>:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 18: 	<span style="color:#0000ff;">char</span> <span style="color:#0000ff;">const</span> * _string;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 19: &#125;;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 20:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 21: <span style="color:#0000ff;">int</span> main()
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 22: &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 23: 	Test instance(&quot;<span style="color:#8b0000;">ala ma kota</span>&quot;);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 24:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 25: 	std::cout &lt;&lt; instance &lt;&lt; std::endl;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 26:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 27: 	<span style="color:#0000ff;">return</span> 0;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 28: &#125;</pre>
</pre></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=25&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2010/09/24/c-convertion-operators/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>Test Live Writera Bety</title>
		<link>http://niezgod.wordpress.com/2010/06/25/test-live-writera-bety/</link>
		<comments>http://niezgod.wordpress.com/2010/06/25/test-live-writera-bety/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 07:51:26 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2010/06/25/test-live-writera-bety</guid>
		<description><![CDATA[Jakiś tam tekst.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=26&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!186" class="bvMsg">
<p>Jakiś tam tekst.</p>
</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=26&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2010/06/25/test-live-writera-bety/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>Chapter 5. Serialization.</title>
		<link>http://niezgod.wordpress.com/2009/10/20/chapter-5-serialization/</link>
		<comments>http://niezgod.wordpress.com/2009/10/20/chapter-5-serialization/#comments</comments>
		<pubDate>Tue, 20 Oct 2009 13:46:26 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/10/20/chapter-5-serialization</guid>
		<description><![CDATA[1. How to serialize an object. In order to be able to serialize type it needs to be marked with [Serialized] attribute. [Serializable] class ObjectToBeSerialized &#123; &#125;   We can serialize such object like this: 1: using System; 2: using System.IO; 3: using System.Runtime.Serialization.Formatters.Binary; 4: 5: [Serializable] 6: class ObjectToBeSerialized 7: &#123; 8: &#125; 9: [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=27&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!163" class="bvMsg">
<h2>1. How to serialize an object.</h2>
<p>In order to be able to serialize type it needs to be marked with [Serialized] attribute.</p>
<pre>[Serializable]
<span>class</span> ObjectToBeSerialized
&#123;
&#125;
</pre>
<p> </p>
<p>We can serialize such object like this:</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.IO;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3: <span style="color:#0000ff;">using</span> System.Runtime.Serialization.Formatters.Binary;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5: [Serializable]
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6: <span style="color:#0000ff;">class</span> ObjectToBeSerialized
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7: &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8: &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10: <span style="color:#0000ff;">class</span> Program
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11: &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:     <span style="color:#0000ff;">void</span> Serialize()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13:     &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 14:         ObjectToBeSerialized instance = <span style="color:#0000ff;">new</span> ObjectToBeSerialized();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 15:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 16:         <span style="color:#0000ff;">using</span> (FileStream stream = File.Create( @&quot;<span style="color:#8b0000;">c:/output.bin</span>&quot;))
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 17:         &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 18:             BinaryFormatter formatter = <span style="color:#0000ff;">new</span> BinaryFormatter();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 19:             formatter.Serialize(stream, instance);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 20:         &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 21:     &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 22: &#125;</pre>
</pre>
<h2>2. How to deserialize object.</h2>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> (FileStream stream = File.Open(@&quot;<span style="color:#8b0000;">c:/output.bin</span>&quot;, FileMode.Open))
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3: &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     BinaryFormatter formatter = <span style="color:#0000ff;">new</span> BinaryFormatter();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     ObjectToBeSerialized instance = (ObjectToBeSerialized )formatter.Deserialize(stream);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6: &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7: </pre>
</pre>
<h2>3. How to handle values that are calculated / do not have to be serialized.</h2>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System.Runtime.Serialization;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4: [Serializable]
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5: <span style="color:#0000ff;">class</span> ObjectToBeSerialized : IDeserializationCallback
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6: &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">int</span> m_value1;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:     [NonSerialized]
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     <span style="color:#0000ff;">private</span> <span style="color:#0000ff;">int</span> m_value2;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:     <span style="color:#0000ff;">public</span> ObjectToBeSerialized( <span style="color:#0000ff;">int</span> _value1)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13:     &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 14:         m_value1 = _value1;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 15:         m_value2 = 10; <span style="color:#008000;">// calculated value</span>
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 16:     &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 17:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 18:     <span style="color:#0000ff;">public</span> <span style="color:#0000ff;">void</span> OnDeserialization(<span style="color:#0000ff;">object</span> sender)
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 19:     &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 20:         m_value2 = 10;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 21:     &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 22: &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 23: </pre>
</pre>
<p>If we don’t want some fields to be serialized we mark them with [NonSerialized].</p>
<p>If we have some values that are not serialized but have to be initialized we can use IDeserializationCallback interface to handle that.</p>
<h2>4. Serialization and version compatibility.</h2>
</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=27&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/10/20/chapter-5-serialization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>Styles in WPF.</title>
		<link>http://niezgod.wordpress.com/2009/05/10/styles-in-wpf/</link>
		<comments>http://niezgod.wordpress.com/2009/05/10/styles-in-wpf/#comments</comments>
		<pubDate>Sun, 10 May 2009 11:34:16 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/05/10/styles-in-wpf</guid>
		<description><![CDATA[Note on article’s inspiration: Article is based almost entirely on Windows Presentation Foundation Unleashed book which I recommend for all WPF learners. Content: 1. What is style. Why do I need it?2. Basic styling scenario. 3. How are elements connected with styles? &#8211; Named and typed styles.4. I have typed style for Control type but [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=30&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!155" class="bvMsg">
<p>Note on article’s inspiration: Article is based almost entirely on Windows Presentation Foundation Unleashed book which I recommend for all WPF learners.</p>
<p>Content:</p>
<p>1. What is style. Why do I need it?<br />2. Basic styling scenario. <br />3. How are elements connected with styles? &#8211; Named and typed styles.<br />4. I have typed style for <em>Control</em> type but it doesn’t work. Not a single subclass of<em> Control</em> has been changed. If I change it to named style everything is ok. What’s wrong? &#8211; Differences between named and typed style in target element’s type matching.</p>
<p><u>1. What is style. Why do I need it?</u></p>
<p>Style is not something you couldn’t live without. It’s yet another mechanism provided to make your life easier. If in your window you have several buttons and you want them all to have their text displayed in red we could set in each one it’s <em>Foreground</em> property’s value to red. However, since we all know the value of gathering such commonalities in one place we will use styles as a very handy tool in such cases. It’s more less like CSS. If you know CSS you get the idea.</p>
<p><u>2. Basic styling scenario.<br /></u><br />We have a window layout containing several buttons.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Window
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     xmlns:x=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     &lt;StackPanel Orientation=&quot;<span style="color:#8b0000;">Vertical</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:         &lt;Button Content=&quot;<span style="color:#8b0000;">First</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:         &lt;Button Content=&quot;<span style="color:#8b0000;">Second</span>&quot; /&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     &lt;/StackPanel&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8: &lt;/Window&gt;</pre>
</pre>
<p>We want all buttons to have their text displayed in red so we define style that will do that for us.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Window
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     xmlns:x=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &lt;Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:         &lt;Style TargetType=&quot;<span style="color:#8b0000;">&#123;x:Type Button&#125;</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:             &lt;Setter Property=&quot;<span style="color:#8b0000;">Foreground</span>&quot; Value=&quot;<span style="color:#8b0000;">Red</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         &lt;/Style&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:     &lt;/Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11:     ...
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13: &lt;/Window&gt;
</pre>
</pre>
<p>And here it is, our first style changing <em>Foreground</em> of all <em>Buttons</em> to red. Generally that’s it. You can add more setters to our style to customize more properties of all <em>Button</em> elements.</p>
<p><u>3. How are elements connected with styles? &#8211; Named and typed styles.</u></p>
<p>This one is important and at first a bit tricky. There are several ways to tell <em>Button’s </em>element instance that it should use our style.</p>
<ul>
<li>define so called <em>named style</em> and assign it to each <em>Button’s</em> instance explicitly
<p>First button has it’s style set. Second one will stay unchanged by our style.
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     &lt;Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:         &lt;Style x:Key=&quot;<span style="color:#8b0000;">buttonStyle</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:             &lt;Setter Property=&quot;<span style="color:#8b0000;">Foreground</span>&quot; Value=&quot;<span style="color:#8b0000;">Red</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &lt;/Style&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &lt;/Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     &lt;StackPanel Orientation=&quot;<span style="color:#8b0000;">Vertical</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         &lt;Button Content=&quot;<span style="color:#8b0000;">First</span>&quot; Style=&quot;<span style="color:#8b0000;">&#123;StaticResource buttonStyle&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:         &lt;Button Content=&quot;<span style="color:#8b0000;">Second</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     &lt;/StackPanel&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11: </pre>
</pre>
<li>define <em>typed style</em> for specific type
<p>In this case all elements of type<em><strong> </strong>Button</em> in window’s scope will have our style set implicitly.<br />You might wonder why our style defined in resources dictionary does not have it’s x:Key set. Well actually it has. It is set implicitly to the value of <em>TargetType</em> attribute.
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     &lt;Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:         &lt;Style TargetType=&quot;<span style="color:#8b0000;">&#123;x:Type Button&#125;</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:             &lt;Setter Property=&quot;<span style="color:#8b0000;">Foreground</span>&quot; Value=&quot;<span style="color:#8b0000;">Red</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &lt;/Style&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &lt;/Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     &lt;StackPanel Orientation=&quot;<span style="color:#8b0000;">Vertical</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         &lt;Button Content=&quot;<span style="color:#8b0000;">First</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:         &lt;Button Content=&quot;<span style="color:#8b0000;">Second</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     &lt;/StackPanel&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11: </pre>
</pre>
</li>
</li>
</ul>
<p>You can choose the one that suits your needs best. Both have their advantages.</p>
<p><u>4. I have typed style for <em>Control</em> type but it doesn’t work. Not a single subclass of<em> Control</em> has been changed. If I change it to named style everything is ok. What’s wrong? &#8211; Differences between named and typed style in target element’s type matching.</u></p>
<p>There is one very important, because hard to be figured out, difference between <em>named </em>and <em>typed </em>style. It is about what type they do match and what they don’t.<br />Let’s look at <em>named</em> style example:</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     &lt;Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:         &lt;Style x:Key=&quot;<span style="color:#8b0000;">controlTemplate</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:             &lt;Setter Property=&quot;<span style="color:#8b0000;">Control.Foreground</span>&quot; Value=&quot;<span style="color:#8b0000;">Red</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &lt;/Style&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &lt;/Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     &lt;StackPanel Orientation=&quot;<span style="color:#8b0000;">Vertical</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         &lt;Button Content=&quot;<span style="color:#8b0000;">First</span>&quot; Style=&quot;<span style="color:#8b0000;">&#123;StaticResource controlTemplate&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:         &lt;Label Content=&quot;<span style="color:#8b0000;">Second</span>&quot; Style=&quot;<span style="color:#8b0000;">&#123;StaticResource controlTemplate&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     &lt;/StackPanel&gt;</pre>
</pre>
<p>In this style we set a <em>Foreground</em> property of <em>Control</em> element. It means that we can set this style to any element that is a subclass of <em>Control</em> and it will still work. This is a very convenient mechanism and it seems to be so natural that when we define <em>typed</em> style like the following we might wonder what’s wrong.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     &lt;Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:         &lt;Style TargetType=&quot;<span style="color:#8b0000;">&#123;x:Type Control&#125;</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:             &lt;Setter Property=&quot;<span style="color:#8b0000;">Control.Foreground</span>&quot; Value=&quot;<span style="color:#8b0000;">Red</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &lt;/Style&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &lt;/Window.Resources&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     &lt;StackPanel Orientation=&quot;<span style="color:#8b0000;">Vertical</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         &lt;Button Content=&quot;<span style="color:#8b0000;">First</span>&quot; /&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:         &lt;Label Content=&quot;<span style="color:#8b0000;">Second</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     &lt;/StackPanel&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11: </pre>
</pre>
<p>It seems to have the same meaning as previous <em>named </em>style but there is a fundamental difference in type matching. <em>Typed</em> style matches only elements of exactly the same types. In our case it would be a <em>Control</em> type. WPF Unleashed explains that it was done to avoid surprises. For example, they say, you can create style for <em>ToggleButton</em> but you don’t want it to be applied to <em>CheckBoxes</em> which is an subclass of a <em>ToggleButton</em>. For <em>named </em>style there is no such problem because you apply style explicitly.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/30/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/30/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/30/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=30&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/05/10/styles-in-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>How to display list of items – MVVM way.</title>
		<link>http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items-%e2%80%93-mvvm-way/</link>
		<comments>http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items-%e2%80%93-mvvm-way/#comments</comments>
		<pubDate>Sun, 03 May 2009 09:02:38 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items-%e2%80%93-mvvm-way</guid>
		<description><![CDATA[  What is that MVVM anyway? The preferred way of connecting data with view in WPF applications seems to be MVVM pattern. MVVM stands for ModelViewViewModel. The whole idea behind it is to create a kind of a bridge between your data and logic at one side and view at the other. By using such [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=28&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!141" class="bvMsg">
<p> </p>
<p><strong>What is that MVVM anyway?</strong></p>
<p>The preferred way of connecting data with view in WPF applications seems to be MVVM pattern. MVVM stands for ModelViewViewModel. The whole idea behind it is to create a kind of a bridge between your data and logic at one side and view at the other. By using such bridge/buffer we avoid hardwiring our logic with view. It allows us to write application data and logic the way it should be written without taking shortcuts and making compromises just to be able to connect such code with a view. If written properly ViewModel can be unit tested which helps a lot in a world of GUI applications which are usually hard to test.</p>
<p>                                                 <a href="http://niezgod.files.wordpress.com/2009/05/f86e2589dc2252adbc2845f2578a7b0a.png" rel="WLPP"><img border="0" src="http://niezgod.files.wordpress.com/2009/05/f86e2589dc2252adbc2845f2578a7b0a.png?w=300" /></a> </p>
<p><strong>A little bit of practice.</strong></p>
<p>Let’s start with a view model. What is a view model? For now let’s just think about view model as an object that provides view with whatever it requires in the form that is convenient for a view. Since view works with a few simple elements like properties containing data it can bind to and commands it can invoke these are two basic elements we will expose in out view model instance.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     <span style="color:#0000ff;">class</span> MainWindowViewModel
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:         <span style="color:#0000ff;">public</span> MainWindowViewModel()
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:             People =
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:                 <span style="color:#0000ff;">new</span> List&lt;Person&gt;()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:                     &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:                         <span style="color:#0000ff;">new</span> Person(&quot;<span style="color:#8b0000;">Arek</span>&quot;, 31),
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:                         <span style="color:#0000ff;">new</span> Person(&quot;<span style="color:#8b0000;">Magda</span>&quot;, 26)
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:                     &#125;;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11:         &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13:         <span style="color:#0000ff;">public</span> IList&lt;Person&gt; People &#123; <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 14:     &#125;</pre>
</pre>
<p>Above we have our view model for main window. It provides view with a list of elements that we will bind to <em>ListView’s</em> control <em>ItemsSource</em> property. </p>
<p>For the sake of completeness of our view model example I have to say a few things about bindings here. Binding, according to MSDN, looks like this:</p>
<p>                                                   <a href="http://niezgod.files.wordpress.com/2009/05/786802d6f563d35526ba152acba28412.png" rel="WLPP"><img border="0" src="http://niezgod.files.wordpress.com/2009/05/786802d6f563d35526ba152acba28412.png?w=300" /></a> </p>
<p>How our example works? Our binding target is <em>ListView</em>, binding source is <em>MainWindowViewModel</em>. Dependency property <em>ItemsSource</em> is bound in XAML to People property in view model. Our binding is in <em>OneWay</em> mode which means that data updates go only from <em>People</em> property to <em>ItemsSource</em>. Actually then don’t. They would if we implemented <em>INotifyPropertyChanged</em> interface in <em>MainWindowViewModel</em>. After that modification on view model looks like that:</p>
<p>(TODO: insert view model with updated implementation)</p>
<p>Now that we have our data we can move to a view implementation.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Window
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     xmlns:x=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml</span>&quot;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     xmlns:local=&quot;<span style="color:#8b0000;">clr-namespace:SimpleList</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:     &lt;Window.Resources&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:         &lt;local:MainWindowViewModel x:Key=&quot;<span style="color:#8b0000;">viewModel</span>&quot; /&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:     &lt;/Window.Resources&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     &lt;ListView
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11:         DataContext=&quot;<span style="color:#8b0000;">&#123;StaticResource viewModel&#125;</span>&quot;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:         ItemsSource=&quot;<span style="color:#8b0000;">&#123;Binding Path=People&#125;</span>&quot; /&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13: &lt;/Window&gt;</pre>
</pre>
<p>As you can see we create an instance of our view model in Windows.Resources section and than use it for setting DataContext of ListView control. First effect of our struggles looks like this. </p>
<p><a href="http://niezgod.files.wordpress.com/2009/05/83f1d367a93c49031024069364222287.png" rel="WLPP"><img border="0" src="http://niezgod.files.wordpress.com/2009/05/83f1d367a93c49031024069364222287.png?w=300" /></a> </p>
</p>
<p>It’s not exactly what we had in mind so what’s wrong? By default list view displays for each item text returned by it’s ToString() method. </p>
<p>One way to improve it would be like this.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     &lt;ListView
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:         DataContext=&quot;<span style="color:#8b0000;">&#123;StaticResource viewModel&#125;</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:         ItemsSource=&quot;<span style="color:#8b0000;">&#123;Binding Path=People&#125;</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &lt;ListView.View&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:             &lt;GridView&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:                 &lt;GridViewColumn Header=&quot;<span style="color:#8b0000;">Name</span>&quot; DisplayMemberBinding=&quot;<span style="color:#8b0000;">&#123;Binding Name&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:                 &lt;GridViewColumn Header=&quot;<span style="color:#8b0000;">Age</span>&quot; DisplayMemberBinding=&quot;<span style="color:#8b0000;">&#123;Binding Age&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:             &lt;/GridView&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:         &lt;/ListView.View&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:     &lt;/ListView&gt;</pre>
</pre>
<p>And the result:</p>
<p><a href="http://niezgod.files.wordpress.com/2009/05/ebc2d3047a3fd84cd4c07f73f733ee04.png" rel="WLPP"><img border="0" src="http://niezgod.files.wordpress.com/2009/05/ebc2d3047a3fd84cd4c07f73f733ee04.png?w=252" /></a> </p>
<p>Better, or maybe like this:</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1:     &lt;ListView
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:         DataContext=&quot;<span style="color:#8b0000;">&#123;StaticResource viewModel&#125;</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:         ItemsSource=&quot;<span style="color:#8b0000;">&#123;Binding Path=People&#125;</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:         &lt;ListView.ItemTemplate&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:             &lt;DataTemplate&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:                 &lt;StackPanel Orientation=&quot;<span style="color:#8b0000;">Horizontal</span>&quot;&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:                     &lt;TextBlock Text=&quot;<span style="color:#8b0000;">Name:</span>&quot; Margin=&quot;<span style="color:#8b0000;">10,0,5,0</span>&quot;/&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:                     &lt;TextBlock FontWeight=&quot;<span style="color:#8b0000;">Bold</span>&quot; Text=&quot;<span style="color:#8b0000;">&#123;Binding Name&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:                     &lt;TextBlock Text=&quot;<span style="color:#8b0000;">Age:</span>&quot; Margin=&quot;<span style="color:#8b0000;">10,0,5,0</span>&quot;/&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:                     &lt;TextBlock FontWeight=&quot;<span style="color:#8b0000;">Bold</span>&quot; Text=&quot;<span style="color:#8b0000;">&#123;Binding Age&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11:                 &lt;/StackPanel&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:             &lt;/DataTemplate&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13:         &lt;/ListView.ItemTemplate&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 14:     &lt;/ListView&gt;</pre>
</pre>
<p><a href="http://niezgod.files.wordpress.com/2009/05/bf2e9f13cb295c4245a3029d76666ff1.png" rel="WLPP"><img border="0" src="http://niezgod.files.wordpress.com/2009/05/bf2e9f13cb295c4245a3029d76666ff1.png?w=300" /></a></p>
<p>As you can see there is a lot of choices. Actually taking into consideration styles, templates, and ExpressionBlend we’ve got countless choices of how to show our data within a control.</p>
<p><a title="http://cid-50268825b2184e6c.skydrive.live.com/self.aspx/.Public/BlogSourceCode/SimpleListViewModelVersion.rar" href="http://348n8g.blu.livefilestore.com/y1pa3z0_Bxk-orycJ9rimDNHmsKrVPAsKGWslOBU5oYlRwbzhQaenm8x_HmOEodjbuHNyZdytYS05VXLroTDkitJg/SimpleListViewModelVersion.rar?download">Full source code for the article.</a></p>
</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/28/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/28/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/28/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=28&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items-%e2%80%93-mvvm-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>

		<media:content url="http://niezgod.files.wordpress.com/2009/05/f86e2589dc2252adbc2845f2578a7b0a.png?w=300" medium="image" />

		<media:content url="http://niezgod.files.wordpress.com/2009/05/786802d6f563d35526ba152acba28412.png?w=300" medium="image" />

		<media:content url="http://niezgod.files.wordpress.com/2009/05/83f1d367a93c49031024069364222287.png?w=300" medium="image" />

		<media:content url="http://niezgod.files.wordpress.com/2009/05/ebc2d3047a3fd84cd4c07f73f733ee04.png?w=252" medium="image" />

		<media:content url="http://niezgod.files.wordpress.com/2009/05/bf2e9f13cb295c4245a3029d76666ff1.png?w=300" medium="image" />
	</item>
		<item>
		<title>How to create WPF application from scratch.</title>
		<link>http://niezgod.wordpress.com/2009/05/03/how-to-create-wpf-application-from-scratch/</link>
		<comments>http://niezgod.wordpress.com/2009/05/03/how-to-create-wpf-application-from-scratch/#comments</comments>
		<pubDate>Sun, 03 May 2009 07:06:37 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/05/03/how-to-create-wpf-application-from-scratch</guid>
		<description><![CDATA[Our goal. Our goal is to create most basic application in WPF. It is an application so we’ll create an Application instance. It is a WPF so we’ll add some UI element, let it be an empty Window instance. Project and it’s basic “must have” settings. First create new empty project. I like to start [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=32&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!140" class="bvMsg">
<p><strong>Our goal.</strong></p>
<p>Our goal is to create most basic application in WPF. It is an application so we’ll create an Application instance. It is a WPF so we’ll add some UI element, let it be an empty Window instance.</p>
<p><strong>Project and it’s basic “must have” settings.</strong></p>
<p>First create new empty project. I like to start with an empty one in order to have everything under control. Later on it’s easy to create template out of our simple application and use it instead of doing everything again and again. When you’re done go to project properties and change application type to Windows Application.</p>
<p><strong>Application definition.</strong></p>
<p>Create Application.xaml file with following content.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Application
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     StartupUri=&quot;<span style="color:#8b0000;">MainWindow.xaml</span>&quot;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     /&gt;</pre>
</pre>
<p>After compiling that project compiler will complain, among other things, about lack of Main method. Visual Studio is able to generate Main method based on that file. In order to do that you have to change in Application.xaml’s properties it’s build action to ApplicationDefinition.</p>
<p>Line two works like a bunch of using statements. It imports a few core namespaces so that we can use core WPF types.<br />Line two instructs Application object to open resource defined in XAML. We can open resources of type Window of NavigationWindow. </p>
<p><strong>Window definition.</strong></p>
<p>In our case MainWindow.xaml contains a definition of new Window class which looks like this:</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Window xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;/&gt;</pre>
</pre>
<p>What we have here is like above: import of core WPF namespaces and definition of new object of class Window.</p>
<p>And that’s it. We’ve got our first GUI application written using WPF library:) I won’t add anything to that example since the core idea was to show the most basic and simple application in WPF. </p>
<p><strong>Why not even shorter?</strong></p>
<p>It would be even more compact if we could treat Application as something similar to a ContentControl</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Application xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     &lt;Window /&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3: &lt;/Application&gt;</pre>
</pre>
<p>but Application cannot have any content so we must stick with this two file solution.</p></div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=32&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/05/03/how-to-create-wpf-application-from-scratch/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>How to display list of items.</title>
		<link>http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items/</link>
		<comments>http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items/#comments</comments>
		<pubDate>Sun, 03 May 2009 06:42:31 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items</guid>
		<description><![CDATA[  In order to display a list of items we obviously need two things: a list of items some UI control prepared for the task of displaying lists WPF is quite liberal about what can be our list of items. It can be a Collection or even IEnumerable. Of course it can work with more [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=31&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!139" class="bvMsg">
<p> </p>
<p>In order to display a list of items we obviously need two things:</p>
<ul>
<li>a list of items</li>
<li>some UI control prepared for the task of displaying lists</li>
</ul>
<p>WPF is quite liberal about what can be our list of items. It can be a <em>Collection</em> or even <em>IEnumerable</em>. Of course it can work with more sophisticated types but more about it some other time.<br />When choosing a control we should know something about <strong>WPF Content Model</strong> idea. For our task best one will be a control implementing ItemsControl content model. When we’ve got our data and control the rest is easy. We just need to bind data to control and we do it like this:</p>
<p>Application instance like usually : </p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Application
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     StartupUri=&quot;<span style="color:#8b0000;">View/MainWindow.xaml</span>&quot;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     /&gt;</pre>
</pre>
<p>MainWindow that way:</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Window
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     xmlns:x=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml</span>&quot;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     x:Class=&quot;<span style="color:#8b0000;">SimpleList.MainWindow</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:     &lt;ListBox ItemsSource=&quot;<span style="color:#8b0000;">&#123;Binding Path=Numbers&#125;</span>&quot;/&gt;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7: &lt;/Window&gt;</pre>
</pre>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">using</span> System.Collections.Generic;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2: <span style="color:#0000ff;">using</span> System.Windows;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4: <span style="color:#0000ff;">namespace</span> SimpleList
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5: &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:     <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,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:     &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         <span style="color:#0000ff;">public</span> MainWindow()
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:         &#123;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10:             InitializeComponent();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 11:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 12:             Numbers = <span style="color:#0000ff;">new</span> List&lt;<span style="color:#0000ff;">int</span>&gt;();
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 13:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 14:             Numbers.Add(1);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 15:             Numbers.Add(2);
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 16:             Numbers.Add(3);
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 17:
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 18:             <span style="color:#0000ff;">this</span>.DataContext = <span style="color:#0000ff;">this</span>;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 19:         &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 20:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 21:         <span style="color:#0000ff;">public</span> IList&lt;<span style="color:#0000ff;">int</span>&gt; Numbers &#123; <span style="color:#0000ff;">get</span>; <span style="color:#0000ff;">set</span>; &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 22:     &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 23: &#125;</pre>
</pre>
<p>Important things we should remember are:</p>
<ul>
<li>Content Model idea</li>
<li><em>DataContext</em> dependency property provided by <em>FrameworkContentElement</em></li>
<li>the whole data binding mechanism</li>
<li>the fact that we can define part of a class as partial class and e.g. set <em>DataContext</em> property that way</li>
</ul>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=31&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/05/03/how-to-display-list-of-items/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create class partially in XAML and partially in code?</title>
		<link>http://niezgod.wordpress.com/2009/05/02/how-to-create-class-partially-in-xaml-and-partially-in-code/</link>
		<comments>http://niezgod.wordpress.com/2009/05/02/how-to-create-class-partially-in-xaml-and-partially-in-code/#comments</comments>
		<pubDate>Sat, 02 May 2009 17:55:49 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/05/02/how-to-create-class-partially-in-xaml-and-partially-in-code</guid>
		<description><![CDATA[C# supplies us with a nice feature allowing to create such splitted class definition. It’s called partial class. Partial classes were added to allow for an easy integration with generated code. For example managed C++ does not support it (some say it is a good thing) which makes it much harder to use WPF with [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=29&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<div id="msgcns!50268825B2184E6C!138" class="bvMsg">
<p>C# supplies us with a nice feature allowing to create such splitted class definition. It’s called partial class. Partial classes were added to allow for an easy integration with generated code. For example managed C++ does not support it (some say it is a good thing) which makes it much harder to use WPF with this language.</p>
<p>In our case it would look like this.</p>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: &lt;Window
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2:     xmlns=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/netfx/2007/xaml/presentation</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     xmlns:x=&quot;<span style="color:#8b0000;">http://schemas.microsoft.com/winfx/2006/xaml</span>&quot;
</pre>
<pre style="background-color:#ffff00;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     x:Class=&quot;<span style="color:#8b0000;">DatabaseGui.MainWindow</span>&quot;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:     &gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7: &lt;/Window&gt;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8: </pre>
</pre>
<pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  1: <span style="color:#0000ff;">namespace</span> Database
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  2: &#123;
</pre>
<pre style="background-color:#ffff00;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  3:     <span style="color:#0000ff;">public</span> partial <span style="color:#0000ff;">class</span> MainWindow : Window
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  4:     &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  5:         <span style="color:#0000ff;">public</span> MainWindow()
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  6:         &#123;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  7:             InitializeComponent();
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  8:         &#125;
</pre>
<pre style="background-color:#fbfbfb;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;">  9:     &#125;
</pre>
<pre style="background-color:#ffffff;width:100%;font-family:consolas,'Courier New',courier,monospace;font-size:12px;margin:0;"> 10: &#125;</pre>
</pre>
<p>From code’s perspective what is important is this <em>partial</em> keyword telling compiler that it is only a partial definition of <em>MainWindow</em> class. Compiler will look for all parts of that class and join them together.</p>
<p>For XAML’s perspective we can omit x:Class attribute. It has more less the same meaning as partial keyword used in code.<br />If we use x:Class in our XAML than, during XAML compilation new file MainWindow.g.cs is created. It contains automatically generated partial class for our <em>MainWindow</em> that does a lot of useful magic behind the scene. It contains a private field for any named element defined in XAML (that’s why you can use such elements so easy in your code-behind). It also contains <em>InitializeComponent</em> method that loads BAML resource, assigns fields to appropriate instances originally declared in XAML, and hook up events if any were specified in XAML. That is why it is so important to call <em>InitializeComponent</em> in <em>MainWindow’s</em> constructor.</p>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/29/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/29/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/29/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=29&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/05/02/how-to-create-class-partially-in-xaml-and-partially-in-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>O yeah!</title>
		<link>http://niezgod.wordpress.com/2009/03/08/o-yeah/</link>
		<comments>http://niezgod.wordpress.com/2009/03/08/o-yeah/#comments</comments>
		<pubDate>Sun, 08 Mar 2009 17:28:40 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/2009/03/08/o-yeah/</guid>
		<description><![CDATA[No, to teraz zobaczymy. Zainstalowałem właśnie plugin Insert Code do Live Writera. Ciekawe jak to się będzie sprawować. 1: using System.Windows; 2: using System; 3: &#160; 4: namespace ListBoxApp 5: { 6: class Program : Application 7: { 8: [STAThread] 9: static void Main() 10: { 11: Program program = new Program(); 12: program.Run( new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=24&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>No, to teraz zobaczymy. Zainstalowałem właśnie plugin Insert Code do Live Writera. Ciekawe jak to się będzie sprawować.</p>
<div class="csharpcode">
<pre class="alt"><span class="lnum">   1:  </span><span class="kwrd">using</span> System.Windows;</pre>
<pre><span class="lnum">   2:  </span><span class="kwrd">using</span> System;</pre>
<pre class="alt"><span class="lnum">   3:  </span>&#160;</pre>
<pre><span class="lnum">   4:  </span><span class="kwrd">namespace</span> ListBoxApp</pre>
<pre class="alt"><span class="lnum">   5:  </span>{</pre>
<pre><span class="lnum">   6:  </span>    <span class="kwrd">class</span> Program : Application</pre>
<pre class="alt"><span class="lnum">   7:  </span>    {</pre>
<pre><span class="lnum">   8:  </span>        [STAThread]</pre>
<pre class="alt"><span class="lnum">   9:  </span>        <span class="kwrd">static</span> <span class="kwrd">void</span> Main()</pre>
<pre><span class="lnum">  10:  </span>        {</pre>
<pre class="alt"><span class="lnum">  11:  </span>            Program program = <span class="kwrd">new</span> Program();</pre>
<pre><span class="lnum">  12:  </span>            program.Run( <span class="kwrd">new</span> MainWindow() );</pre>
<pre class="alt"><span class="lnum">  13:  </span>        }</pre>
<pre><span class="lnum">  14:  </span>    }</pre>
<pre class="alt"><span class="lnum">  15:  </span>}</pre>
</div>
<p>.csharpcode, .csharpcode pre<br />
{<br />
	font-size: small;<br />
	color: black;<br />
	font-family: consolas, &#8220;Courier New&#8221;, courier, monospace;<br />
	background-color: #ffffff;<br />
	/*white-space: pre;*/<br />
}<br />
.csharpcode pre { margin: 0em; }<br />
.csharpcode .rem { color: #008000; }<br />
.csharpcode .kwrd { color: #0000ff; }<br />
.csharpcode .str { color: #006080; }<br />
.csharpcode .op { color: #0000c0; }<br />
.csharpcode .preproc { color: #cc6633; }<br />
.csharpcode .asp { background-color: #ffff00; }<br />
.csharpcode .html { color: #800000; }<br />
.csharpcode .attr { color: #ff0000; }<br />
.csharpcode .alt<br />
{<br />
	background-color: #f4f4f4;<br />
	width: 100%;<br />
	margin: 0em;<br />
}<br />
.csharpcode .lnum { color: #606060; }</p>
<p>Hmm, jakiejś rewelacji nie widzę, ale bez przesady. W końcu chodzi o to żeby coś w końcu napisać na tym blogu, a nie w nieskończoność szukać idealnego syntax higlightera.</p>
<p>No to git. Sprawę uznajemy za załatwioną.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/24/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/24/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/24/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=24&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/03/08/o-yeah/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
		<item>
		<title>Test post.</title>
		<link>http://niezgod.wordpress.com/2009/03/07/test-post/</link>
		<comments>http://niezgod.wordpress.com/2009/03/07/test-post/#comments</comments>
		<pubDate>Sat, 07 Mar 2009 21:27:09 +0000</pubDate>
		<dc:creator>niezgod</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://niezgod.wordpress.com/?p=21</guid>
		<description><![CDATA[This is just an example post to check how wordpress.com is able to handle c# source code. I&#8217;ve been trying to get it working for some time now but it looks like there is no way to do it easly. It&#8217;s a pity wordpress.com doesn&#8217;t have SyntaxHighlighter script from Alex Gorbatchev installed. It&#8217;d be so [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=21&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is just an example post to check how wordpress.com is able to handle c# source code. I&#8217;ve been trying to get it working for some time now but it looks like there is no way to do it easly. It&#8217;s a pity wordpress.com doesn&#8217;t have SyntaxHighlighter script from Alex Gorbatchev installed. It&#8217;d be so nice and easy. Anyway it&#8217;s not installed so we need to do it some other way.<br />
Let&#8217;s find out what the output of http://dotnetslackers.com/articles/csharpformat.aspx looks like.</p>
<pre class="csharpcode">
<span class="kwrd">using</span> System.Windows;
<span class="kwrd">using</span> System;

<span class="kwrd">namespace</span> ListBoxApp
{
    <span class="kwrd">class</span> Program : Application
    {
        [STAThread]
        <span class="kwrd">static</span> <span class="kwrd">void</span> Main()
        {
            Program program = <span class="kwrd">new</span> Program();
            program.Run( <span class="kwrd">new</span> MainWindow() );
        }
    }
}</pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/niezgod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/niezgod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/niezgod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/niezgod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/niezgod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/niezgod.wordpress.com/21/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/niezgod.wordpress.com/21/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/niezgod.wordpress.com/21/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=niezgod.wordpress.com&amp;blog=2658100&amp;post=21&amp;subd=niezgod&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://niezgod.wordpress.com/2009/03/07/test-post/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/fc867db7a33230853dd7e8f23eaf3165?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">niezgod</media:title>
		</media:content>
	</item>
	</channel>
</rss>
