<?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>Stay hungry, stay foolish.</title>
	<atom:link href="http://bezieur.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bezieur.wordpress.com</link>
	<description>About my .NET programming...</description>
	<lastBuildDate>Fri, 19 Jun 2009 22:09:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bezieur.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Stay hungry, stay foolish.</title>
		<link>http://bezieur.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bezieur.wordpress.com/osd.xml" title="Stay hungry, stay foolish." />
	<atom:link rel='hub' href='http://bezieur.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Entity .ToString() and Stackoverflow</title>
		<link>http://bezieur.wordpress.com/2009/06/19/entity-tostring-and-stackoverflow/</link>
		<comments>http://bezieur.wordpress.com/2009/06/19/entity-tostring-and-stackoverflow/#comments</comments>
		<pubDate>Fri, 19 Jun 2009 21:59:59 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/2009/06/19/entity-tostring-and-stackoverflow/</guid>
		<description><![CDATA[In my NHibernate core classes I decided to have more informative ToString method, and so I’ve done something like that: public override string ToString() { StringBuilder sb = new StringBuilder(); var props = TypeDescriptor.GetProperties(this); foreach (PropertyDescriptor p in props) { sb.AppendFormat("{0} : {1} \n", p.Name, p.GetValue(this)); } return sb.ToString(); } Very simple, isn’t it? … [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=95&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In my NHibernate core classes I decided to have more informative ToString method, and so I’ve done something like that:</p>
</p>
<div id="codeSnippetWrapper">
<div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:db76e548-085d-4e3b-802c-280a76cd8915" class="wlWriterEditableSmartContent">
<pre style="background-color:White;overflow:auto;"><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> ToString()
{
  StringBuilder sb </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> StringBuilder();
  var props </span><span style="color:#000000;">=</span><span style="color:#000000;"> TypeDescriptor.GetProperties(</span><span style="color:#0000FF;">this</span><span style="color:#000000;">);
  </span><span style="color:#0000FF;">foreach</span><span style="color:#000000;"> (PropertyDescriptor p </span><span style="color:#0000FF;">in</span><span style="color:#000000;"> props)
  {
      sb.AppendFormat(</span><span style="color:#800000;">"</span><span style="color:#800000;">{0} : {1} \n</span><span style="color:#800000;">"</span><span style="color:#000000;">, p.Name, p.GetValue(</span><span style="color:#0000FF;">this</span><span style="color:#000000;">));
  }
  </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> sb.ToString();
}
</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p></div>
<p>Very simple, isn’t it? … But it is wrong!</p>
<p>The code above results in Stackoverflow exception. You will not find any information on that in <a href="http://google.com">search engine</a> as certain <a href="http://stackoverflow.com/">very popular site</a> has such name <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' />  and so all find results points there..</p>
<p>Ok so my new ToString():</p>
<p><div style="display:inline;float:none;margin:0;padding:0;" id="scid:57F11A72-B0E5-49c7-9094-E3A15BD5B5E6:32ff3a74-051f-4cd9-8c64-4920c50aafda" class="wlWriterEditableSmartContent">
<pre style="background-color:#FFFFFF;overflow:auto;"><span style="color:#0000FF;">public</span><span style="color:#000000;"> </span><span style="color:#0000FF;">override</span><span style="color:#000000;"> </span><span style="color:#0000FF;">string</span><span style="color:#000000;"> ToString()
{
  StringBuilder sb </span><span style="color:#000000;">=</span><span style="color:#000000;"> </span><span style="color:#0000FF;">new</span><span style="color:#000000;"> StringBuilder();
  sb.Append(</span><span style="color:#0000FF;">base</span><span style="color:#000000;">.ToString());

  var props </span><span style="color:#000000;">=</span><span style="color:#000000;"> GetType().GetProperties()
      .Where(p </span><span style="color:#000000;">=&gt;</span><span style="color:#000000;"> Attribute.IsDefined(p, </span><span style="color:#0000FF;">typeof</span><span style="color:#000000;">(DomainSignatureAttribute), </span><span style="color:#0000FF;">true</span><span style="color:#000000;">) </span><span style="color:#000000;">&amp;&amp;</span><span style="color:#000000;">
      (</span><span style="color:#000000;">!</span><span style="color:#000000;">p.PropertyType.IsSubclassOf(</span><span style="color:#0000FF;">typeof</span><span style="color:#000000;">(IEnumerable))) </span><span style="color:#000000;">&amp;&amp;</span><span style="color:#000000;">
      (</span><span style="color:#000000;">!</span><span style="color:#000000;">p.PropertyType.IsSubclassOf(</span><span style="color:#0000FF;">typeof</span><span style="color:#000000;">(BaseObject))));

  </span><span style="color:#0000FF;">if</span><span style="color:#000000;"> (props.Count() </span><span style="color:#000000;">&gt;</span><span style="color:#000000;"> </span><span style="color:#800080;">0</span><span style="color:#000000;">)
  {
      sb.AppendLine();
  }

  </span><span style="color:#0000FF;">foreach</span><span style="color:#000000;"> (PropertyInfo p </span><span style="color:#0000FF;">in</span><span style="color:#000000;"> props)
  {
        sb.AppendFormat(</span><span style="color:#800000;">"</span><span style="color:#800000;">{0} : {1} \n</span><span style="color:#800000;">"</span><span style="color:#000000;">, p.Name, p.GetValue(</span><span style="color:#0000FF;">this</span><span style="color:#000000;">, </span><span style="color:#0000FF;">null</span><span style="color:#000000;">));
  }
  </span><span style="color:#0000FF;">return</span><span style="color:#000000;"> sb.ToString();
}</span></pre>
<p><!-- Code inserted with Steve Dunn's Windows Live Writer Code Formatter Plugin.  http://dunnhq.com --></div>
<p>As I use a concept of DomainSignatureAttribue (from <a href="http://code.google.com/p/sharp-architecture/">Sharp Architecture</a>) and so I decided to show only those properties in ToString() method. I filter collections and other entities that my class refer out, as well, so there should be no circular code references any more.</p>
<p>And I’ve get rid of stack overflow <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> .</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/95/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/95/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/95/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=95&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/06/19/entity-tostring-and-stackoverflow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>Adorner border issue?</title>
		<link>http://bezieur.wordpress.com/2009/06/17/adorner-border-issue/</link>
		<comments>http://bezieur.wordpress.com/2009/06/17/adorner-border-issue/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 22:19:33 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=90</guid>
		<description><![CDATA[First look at sample window: The adorner&#8217;s right border is shift a little, well it does not looks nice. Any ideas? &#8230; The solution is quite simple &#8230; the window is too small to contain adorner, as the TextBox inside fulfills the windows width, and so the solution is quite simple: I need just to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=90&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>First look at sample window:<br />
<img src="http://bezieur.files.wordpress.com/2009/06/adornertest.png?w=187&#038;h=171" alt="Adornertest" title="Adornertest" width="187" height="171" class="alignnone size-full wp-image-91" /><br />
The adorner&#8217;s right border is shift a little, well it does not looks nice.<br />
Any ideas?<br />
&#8230;<br />
The solution is quite simple &#8230; the window is too small to contain adorner, as the TextBox inside fulfills the windows width, and so the solution is quite simple: I need just to add some margins, that&#8217;s it.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/90/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/90/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/90/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=90&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/06/17/adorner-border-issue/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>

		<media:content url="http://bezieur.files.wordpress.com/2009/06/adornertest.png" medium="image">
			<media:title type="html">Adornertest</media:title>
		</media:content>
	</item>
		<item>
		<title>NHibernate types conversion &#8211; be careful !!!!</title>
		<link>http://bezieur.wordpress.com/2009/06/09/nhibernate-types-conversion-be-careful/</link>
		<comments>http://bezieur.wordpress.com/2009/06/09/nhibernate-types-conversion-be-careful/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 20:57:59 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=87</guid>
		<description><![CDATA[I&#8217;ve mostly operate on well known types: int, string and DateTime, and I&#8217;ve newer suspect that some hidden dragon is there&#8230; And so once I&#8217;ve decided to be more specific, we&#8217;ve got ushorts and other beautiful types.. And there is my waring: BE VERY CONSISTENT. If your property is ushort your mapping must be type [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=87&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve mostly operate on well known types: int, string and DateTime, and I&#8217;ve newer suspect that some hidden dragon is there&#8230; And so once I&#8217;ve decided to be more specific, we&#8217;ve got ushorts and other beautiful types..<br />
And there is my waring: BE VERY CONSISTENT. If your property is ushort your mapping must be type UInt16, if you map it as Int16 you will end with Invalid Cast, and with no precise clue which property is guilty!<br />
So again my piece of advice: if you mean <strong>ushort </strong>map <strong>UInt16</strong>, not anything else.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/87/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/87/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/87/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=87&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/06/09/nhibernate-types-conversion-be-careful/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>Too many NHibernate libraries in one project</title>
		<link>http://bezieur.wordpress.com/2009/06/09/too-many-nhibernate-libraries-in-one-project/</link>
		<comments>http://bezieur.wordpress.com/2009/06/09/too-many-nhibernate-libraries-in-one-project/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 15:01:04 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=84</guid>
		<description><![CDATA[I&#8217;ve always tried to work with as many super new, hot libraries as possible, and so I&#8217;ve put myself into a trap. One of my projects used: NHibernate, NHibernate addins, Fluent NHibernate, NHibernate Validator and Castle Windsor obviously. Four NHibernateXXX projects in one and all compiled from their trunks, as you can imagine it was [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=84&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve always tried to work with as many super new, hot libraries as possible, and so I&#8217;ve put myself into a trap.<br />
One of my projects used: NHibernate, NHibernate addins, Fluent NHibernate, NHibernate Validator and Castle Windsor obviously.<br />
Four NHibernateXXX projects in one and all compiled from their trunks, as you can imagine it was quite funny to synchronize all common necessary libraries. But as time passed it wast not so funny, so I decided to some limitation. So I&#8217;ve get rid of Fluent NHibernate. And guess what: nothing terrible happed, quite contrary now I don&#8217;t have any problems with consistency as all the rest is updated in their trunks by their (great) teams. And additionally configuring NHibernate in xml is not a problem at all, as intellisense works good, and it is good documented. (What I miss is conventions from Fluent NH, but now I can be super up-to-date) <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/84/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/84/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/84/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=84&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/06/09/too-many-nhibernate-libraries-in-one-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>Get desciptive name for a UI control</title>
		<link>http://bezieur.wordpress.com/2009/06/09/get-desciptive-name-for-a-ui-control/</link>
		<comments>http://bezieur.wordpress.com/2009/06/09/get-desciptive-name-for-a-ui-control/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 14:43:33 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=76</guid>
		<description><![CDATA[Hi, When dealing with UI validation functions I&#8217;ve found that I need to get a good looking, descriptive name for my UI elements: textboxes, comboboxes etc.. and so if that elements have labels with target property so the rest is quite simple: private string GetLabelTextForControl(DependencyObject targetElement, DependencyObject searchIn) { for (int i = 0; i [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=76&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi,<br />
When dealing with UI validation functions I&#8217;ve found that I need to get a good looking, descriptive name for my UI elements: textboxes, comboboxes etc.. and so if that elements have labels with target property so the rest is quite simple:</p>
<pre class="brush: csharp;">
        private string GetLabelTextForControl(DependencyObject targetElement, DependencyObject searchIn)
        {
            for (int i = 0; i &lt; VisualTreeHelper.GetChildrenCount(searchIn); i++)
            {
                DependencyObject v = VisualTreeHelper.GetChild(searchIn, i);
                Label childVisual = v as Label;
                if (childVisual != null)
                {
                    if (childVisual.Target == targetElement)
                    {
                        return childVisual.Content.ToString();
                    }
                }
                else
                {
                    if (VisualTreeHelper.GetChildrenCount(v) &gt; 0)
                    {
                        string respValue = GetLabelTextForControl(targetElement, v);
                        if (!string.IsNullOrEmpty(respValue))
                        {
                            return respValue;
                        }
                    }
                }
            }

            return string.Empty;
        }
</pre>
<p>It&#8217;s quick and dirty but it works. The parameters are: the control which name you are searching and the panel, user control or window in which you are searching.<br />
It works if you have Target property set e.g.:</p>
<pre class="brush: xml;">
        &lt;Label Target=&quot;{Binding ElementName=txtBox}&quot; Content=&quot;{Binding Path=Caption, ElementName=me}&quot; /&gt;
        &lt;TextBox x:Name=&quot;txtBox&quot; AcceptsReturn=&quot;True&quot; VerticalScrollBarVisibility=&quot;Auto&quot; TextWrapping=&quot;Wrap&quot;/&gt;
</pre>
<p>So it&#8217;s just a quick answer to a question: How to get labels for UI Controls in WPF, but I&#8217;d gladly invite cleaner solution.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/76/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/76/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/76/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=76&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/06/09/get-desciptive-name-for-a-ui-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>uNHaddins + Fluent NHibernate</title>
		<link>http://bezieur.wordpress.com/2009/03/18/unhaddins-fluent-nhibernate/</link>
		<comments>http://bezieur.wordpress.com/2009/03/18/unhaddins-fluent-nhibernate/#comments</comments>
		<pubDate>Wed, 18 Mar 2009 14:26:04 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[NHibernate]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=71</guid>
		<description><![CDATA[Well it is nothing super creative, but it took me a while to do that. And so you have probably two possible solutions: write your own implementation of IConfiguratorProvider, or as I did configure the default one: var nhConfigurator = new DefaultSessionFactoryConfigurationProvider(); nhConfigurator.AfterConfigure += nhConfigurator_AfterConfigure; var sfp = new SessionFactoryProvider(nhConfigurator); container.Register(Component .For&#60;ISessionFactoryProvider&#62;() .Named(&#34;sessionFactoryProvider&#34;) .Instance(sfp)); static [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=71&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Well it is nothing super creative, but it took me a while to do that.<br />
And so you have probably two possible solutions: write your own implementation of IConfiguratorProvider, or as I did configure the default one:</p>
<pre class="brush: csharp;">
var nhConfigurator = new DefaultSessionFactoryConfigurationProvider();
nhConfigurator.AfterConfigure += nhConfigurator_AfterConfigure;
var sfp = new SessionFactoryProvider(nhConfigurator);

container.Register(Component
                               .For&lt;ISessionFactoryProvider&gt;()
                               .Named(&quot;sessionFactoryProvider&quot;)
                               .Instance(sfp));

static void nhConfigurator_AfterConfigure(object sender, ConfigurationEventArgs e)
{
     NHConfigurationBuilder.AddMappingAssembliesTo(e.Configuration,  new string[] { &quot;XXXX.Dal.dll&quot; });
}
</pre>
<p>And that&#8217;s it. The ConfigurationEventArgs expose configuration object as you can see. That event could also be used to export db schema, as it is done in <a href="http://code.google.com/p/unhaddins/">uNHaddins</a> examples.<br />
Additionally I&#8217;ve found useful information in <a href="http://gustavoringel.blogspot.com/2009/02/unhaddins-conversation-additions.html">Gustavo Ringel </a>blog. And of course in <a href="http://www.fabiomaulo.blogspot.com/">HunabKu</a> blog.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/71/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/71/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/71/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=71&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/03/18/unhaddins-fluent-nhibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>Simple wpf user control</title>
		<link>http://bezieur.wordpress.com/2009/02/26/simple-wpf-user-control/</link>
		<comments>http://bezieur.wordpress.com/2009/02/26/simple-wpf-user-control/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 23:00:26 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=64</guid>
		<description><![CDATA[We should have our work get easier, shouldn&#8217;t we? So I don&#8217;t like to repeat label + text box all over, that duet is a good choose for user control, and so it is: (and keep remember, I&#8217;m still learning..) PlainTextBox.xaml: &#60;UserControl x:Class=&#34;PlainTextBox&#34; xmlns=&#34;http://schemas.microsoft.com/winfx/2006/xaml/presentation&#34; xmlns:x=&#34;http://schemas.microsoft.com/winfx/2006/xaml&#34; x:Name=&#34;me&#34; Style=&#34;{StaticResource MyControlStyle}&#34;&#62; &#60;UserControl.Resources&#62; &#60;ResourceDictionary&#62; &#60;Style TargetType=&#34;TextBox&#34; BasedOn=&#34;{StaticResource {x:Type TextBox}}&#34;&#62; [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=64&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>We should have our work get easier, shouldn&#8217;t we?<br />
So I don&#8217;t like to repeat label + text box all over, that duet is a good choose for user control, and so it is:<br />
(and keep remember, I&#8217;m still learning..)</p>
<p>PlainTextBox.xaml:</p>
<pre class="brush: xml;">
&lt;UserControl x:Class=&quot;PlainTextBox&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    x:Name=&quot;me&quot;
    Style=&quot;{StaticResource MyControlStyle}&quot;&gt;
    &lt;UserControl.Resources&gt;
        &lt;ResourceDictionary&gt;
            &lt;Style TargetType=&quot;TextBox&quot; BasedOn=&quot;{StaticResource {x:Type TextBox}}&quot;&gt;
            &lt;Style.Triggers&gt;
                &lt;Trigger Property=&quot;Validation.HasError&quot; Value=&quot;true&quot;&gt;
                    &lt;Setter Property=&quot;ToolTip&quot;
                            Value=&quot;{Binding RelativeSource={x:Static RelativeSource.Self},
                            Path=(Validation.Errors)[0].ErrorContent}&quot;/&gt;
                &lt;/Trigger&gt;
            &lt;/Style.Triggers&gt;
        &lt;/Style&gt;
        &lt;/ResourceDictionary&gt;
    &lt;/UserControl.Resources&gt;
    &lt;StackPanel&gt;
        &lt;Label Target=&quot;{Binding ElementName=txtBox}&quot; Content=&quot;{Binding Path=Caption, ElementName=me}&quot; /&gt;
        &lt;TextBox x:Name=&quot;txtBox&quot;/&gt;
    &lt;/StackPanel&gt;
&lt;/UserControl&gt;
</pre>
<p>PlainTextBox.xaml.cs</p>
<pre class="brush: csharp;">
   public partial class PlainTextBox : UserControl
    {
        // Using a DependencyProperty as the backing store for Caption.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty CaptionProperty =
            DependencyProperty.Register(&quot;Caption&quot;, typeof(string), typeof(PlainTextBox), new UIPropertyMetadata(&quot;&quot;));

        // Using a DependencyProperty as the backing store for Path.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PathProperty =
            DependencyProperty.Register(&quot;PathName&quot;,
                typeof(string),
                typeof(PlainTextBox),
                new PropertyMetadata(&quot;&quot;, MyPathChanged));

        public PlainTextBox()
        {
            InitializeComponent();
        }

        public string Caption
        {
            get { return (string)GetValue(CaptionProperty); }
            set { SetValue(CaptionProperty, value); }
        }

        public string PathName
        {
            get { return (string)GetValue(PathProperty); }
            set { SetValue(PathProperty, value); }
        }

        private static void MyPathChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            PlainTextBox tc = d as PlainTextBox;
            Binding myBinding = new Binding(&quot;MyDataProperty&quot;);
            myBinding.Mode = BindingMode.TwoWay;
            myBinding.Path = new PropertyPath(tc.PathName);
            myBinding.ValidatesOnDataErrors = true;
            myBinding.ValidatesOnExceptions = true;
            tc.txtBox.SetBinding(TextBox.TextProperty, myBinding);
        }
    }
</pre>
<p>And usage:</p>
<pre class="brush: xml;">
 &lt;ctr:PlainTextBox Caption=&quot;Last name&quot; PathName=&quot;DetailData.LastName&quot;&gt;&lt;/ctr:PlainTextBox&gt;
</pre>
<p>And that way all data binding attributes are encapsulated in user control, so I do not need repeat that I want validation on errors all over in my code.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/64/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/64/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/64/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=64&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/02/26/simple-wpf-user-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>Pager class</title>
		<link>http://bezieur.wordpress.com/2009/02/24/pager-class/</link>
		<comments>http://bezieur.wordpress.com/2009/02/24/pager-class/#comments</comments>
		<pubDate>Tue, 24 Feb 2009 11:02:09 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=55</guid>
		<description><![CDATA[In previous post I&#8217;ve used Pager class which is contained in my grid controller, and so there is an implementation: [NotifyPropertyChanged] public class Pager : IPager { private uint m_CurrentPage; private uint m_PageSize; private uint m_RecordFrom; private uint m_RecordTo; public Pager() { m_PageSize = 50; PageNumber = 0; } public uint PageNumber { get { [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=55&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>In previous post I&#8217;ve used Pager class which is contained in my grid controller, and so there is an implementation:</p>
<pre class="brush: csharp;">
    [NotifyPropertyChanged]
    public class Pager : IPager
    {
        private uint m_CurrentPage;

        private uint m_PageSize;

        private uint m_RecordFrom;

        private uint m_RecordTo;

        public Pager()
        {
            m_PageSize = 50;
            PageNumber = 0;
        }

        public uint PageNumber
        {
            get
            {
                return m_CurrentPage;
            }
            set
            {
                uint from = m_PageSize * value;
                RecordFrom = from;
                RecordTo = from + m_PageSize  - 1;
                m_CurrentPage = value;
            }
        }

        public uint PageSize
        {
            get
            {
                return m_PageSize;
            }
            set
            {
                m_PageSize = value;
                PageNumber = 0;
            }
        }

        public uint RecordFrom
        {
            get
            {
                return m_RecordFrom;
            }
            private set
            {
                m_RecordFrom = value;
                RecordFromDisplay = value + 1;
            }
        }

        public uint RecordFromDisplay { get; private set; }

        public uint RecordTo
        {
            get
            {
                return m_RecordTo;
            }
            private set
            {
                m_RecordTo = value;
                RecordToDisplay = value + 1;
            }
        }

         public uint RecordToDisplay { get; private set; }

        public event EventHandler PagesChanged;

        public bool CanPreviousPage()
        {
            return PageNumber &gt; 0;
        }

        public void NextPage()
        {
            PageNumber++;
            OnPagesChanged();
        }

        [Preview(&quot;CanPreviousPage&quot;)]
        [Dependencies(&quot;PageNumber&quot;)]
        public void PreviousPage()
        {
            if (CanPreviousPage())
            {
                PageNumber--;
                OnPagesChanged();
            }
        }

        private void OnPagesChanged()
        {
            if (PagesChanged != null)
            {
                PagesChanged(this, EventArgs.Empty);
            }
        }
    }
</pre>
<p>and the view:</p>
<pre class="brush: xml;">
&lt;UserControl x:Class=&quot;GridToolbar&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:ca=&quot;clr-namespace:Caliburn.Actions;assembly=Caliburn.Actions&quot;
    xmlns:cm=&quot;clr-namespace:Caliburn.RoutedUIMessaging;assembly=Caliburn.RoutedUIMessaging&quot;
    &gt;
    &lt;Action.Target&gt;
        &lt;Binding /&gt;
    &lt;/Action.Target&gt;

    &lt;UserControl.Resources&gt;
        &lt;ResourceDictionary&gt;
                &lt;ResourceDictionary.MergedDictionaries&gt;
                &lt;ResourceDictionary Source=&quot;MainWindowResources.xaml&quot; /&gt;
            &lt;/ResourceDictionary.MergedDictionaries&gt;
        &lt;/ResourceDictionary&gt;
    &lt;/UserControl.Resources&gt;
    &lt;DockPanel LastChildFill=&quot;True&quot;&gt;
        &lt;ToolBar DockPanel.Dock=&quot;Top&quot;&gt;
            &lt;Button ca:Action.Target=&quot;{Binding Pager}&quot; cm:Message.Attach=&quot;PreviousPage&quot;&gt;
                &lt;Image Source=&quot;..\Resources\Images\arrow_180.png&quot; Opacity=&quot;1&quot; Stretch=&quot;None&quot; VerticalAlignment=&quot;Center&quot; /&gt;
            &lt;/Button&gt;
            &lt;Label Content=&quot;{Binding Pager.RecordFromDisplay}&quot;&gt;&lt;/Label&gt;
            &lt;Label&gt;...&lt;/Label&gt;
            &lt;Label Content=&quot;{Binding Pager.RecordToDisplay}&quot;&gt;&lt;/Label&gt;
            &lt;Button ca:Action.Target=&quot;{Binding Pager}&quot; cm:Message.Attach=&quot;NextPage&quot;&gt;
                &lt;Image Source=&quot;..\Resources\Images\arrow.png&quot; Opacity=&quot;1&quot; Stretch=&quot;None&quot; VerticalAlignment=&quot;Center&quot; /&gt;
            &lt;/Button&gt;
            &lt;Separator&gt;&lt;/Separator&gt;
            &lt;Button cm:Message.Attach=&quot;OnShowDetail&quot;&gt;
                &lt;Image Source=&quot;..\Resources\Images\document_horizontal_text.png&quot; Opacity=&quot;1&quot; Stretch=&quot;None&quot; VerticalAlignment=&quot;Center&quot; /&gt;
            &lt;/Button&gt;
            &lt;Button cm:Message.Attach=&quot;LoadData&quot;&gt;
                &lt;Image Source=&quot;..\Resources\Images\arrow_circle_double.png&quot; Opacity=&quot;1&quot; Stretch=&quot;None&quot; VerticalAlignment=&quot;Center&quot; /&gt;
            &lt;/Button&gt;
            &lt;Button cm:Message.Attach=&quot;OnGoToFilter&quot;&gt;
                &lt;Image Source=&quot;..\Resources\Images\binocular.png&quot; Opacity=&quot;1&quot; Stretch=&quot;None&quot; VerticalAlignment=&quot;Center&quot; /&gt;
            &lt;/Button&gt;
        &lt;/ToolBar&gt;
    &lt;/DockPanel&gt;
&lt;/UserControl&gt;
</pre>
<p>Please notice how <a href="http://www.codeplex.com/caliburn">caliburn</a> simplified the code! Because the DataContext is set to a grid controller certain actions could be bound to it directly, like OnGoToFilter, but buttons for paging was to be bound to the Pager class, so additionally I had to indicate the action target. Clean and simple.</p>
<p>And how it looks like:</p>
<p><img class="alignnone size-full wp-image-60" title="wpftoolbar" src="http://bezieur.files.wordpress.com/2009/02/wpftoolbar2.jpg?w=510" alt="wpftoolbar" /></p>
<p>It is without any particular styling. The left one of course, the right one is from my winforms project. And don&#8217;t complain on blury text and images, MS will fix it soon (I hope so).</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/55/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/55/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/55/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=55&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/02/24/pager-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>

		<media:content url="http://bezieur.files.wordpress.com/2009/02/wpftoolbar2.jpg" medium="image">
			<media:title type="html">wpftoolbar</media:title>
		</media:content>
	</item>
		<item>
		<title>Generic grid view</title>
		<link>http://bezieur.wordpress.com/2009/02/23/generic-grid-view/</link>
		<comments>http://bezieur.wordpress.com/2009/02/23/generic-grid-view/#comments</comments>
		<pubDate>Mon, 23 Feb 2009 16:00:58 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=42</guid>
		<description><![CDATA[As the best way to learn something is to play with it, so I build a little mvvm data system. Actually I&#8217;ve got similar with winforms (MVP with passive views), so I try to add another UI to the system. A common data from contains three components: filter grid view and detail view (of one [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=42&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As the best way to learn something is to play with it, so I build a little mvvm data system. Actually I&#8217;ve got similar with winforms (MVP with passive views), so I try to add another UI to the system.</p>
<p>A common data from contains three components:</p>
<ul>
<li>filter</li>
<li>grid view and</li>
<li>detail view (of one record)</li>
</ul>
<p>Because grid view is the same for all data objects (with the difference of the columns), I decided to keep it as a one user control and only configure columns.</p>
<p>And so is my solution:</p>
<p>GridController.cs:</p>
<pre class="brush: csharp;">
    [NotifyPropertyChanged]
    public abstract class GridController : ViewModelBase, IGridController, IGridConfiguator
    {
        private IDictionary&lt;string, object&gt; m_Criteria;

        protected Type m_CurrentType;

        private IPager m_Pager;

        public bool AllowMultiselect { get; set; }

        public object CurrentItem { get; set; }

        public IMultidataRepository DataRepository { get; set; }

        /// &lt;summary&gt;
        /// Gets or sets the grid data. Data can be aded by that property, or by ShowData function
        /// &lt;/summary&gt;
        /// &lt;value&gt;The grid data.&lt;/value&gt;
        public IList GridData { get; protected set; }

        public IPager Pager
        {
            get
            {
                return m_Pager;
            }
            set
            {
                m_Pager = value;
                m_Pager.PagesChanged += Pager_PagesChanged;
            }
        }

        public event EventHandler GoToFilter;

        public event EventHandler ShowDetail;

        /// &lt;summary&gt;
        /// Loads the data. If m_Criteria are null or empty then it should equal as GetAll()
        /// &lt;/summary&gt;
        public void LoadData()
        {
            GridData.Clear();
            using (new Workspace())
            {
                var x = DataRepository.FilterByProperties(m_CurrentType, m_Criteria, null, Pager.RecordFrom, Pager.PageSize);
                foreach (var item in x)
                {
                    GridData.Add(item);
                }
            }
        }

        public void OnGoToFilter()
        {
            if (GoToFilter != null)
            {
                GoToFilter(this, EventArgs.Empty);
            }
        }

        public void OnShowDetail()
        {
            if (ShowDetail != null)
            {
                ShowDetail(this, EventArgs.Empty);
            }
        }

        /// &lt;summary&gt;
        /// Shows the data. Data will be loaded form the storage and displayed in a grid
        /// &lt;/summary&gt;
        ///
&lt;param name=&quot;criteria&quot;&gt;The criteria.&lt;/param&gt;
        public void ShowData(IDictionary&lt;string, object&gt; criteria)
        {
            m_Criteria = criteria;
            LoadData();
        }

        private void Pager_PagesChanged(object sender, EventArgs e)
        {
            LoadData();
        }

        public virtual void Configure(DataGrid gridToConfigure)
        {
        }
    }
</pre>
<p>It is a ModeView class which contains IPager class for switching between pages of records.<br />
NotifyPropertyChanged class attribute is for Postsharp to add required code for properties.<br />
And the GenericView:</p>
<pre class="brush: xml;">
    &lt;StackPanel&gt;
        &lt;local:GridToolbar&gt;&lt;/local:GridToolbar&gt;
        &lt;wt:DataGrid x:Name=&quot;GridWithData&quot; ItemsSource=&quot;{Binding GridData, Mode=OneWay}&quot; SelectedItem=&quot;{Binding CurrentItem}&quot;&gt;
        &lt;/wt:DataGrid&gt;
    &lt;/StackPanel&gt;
</pre>
<p>Generic grid view contains grid toolbar and a grid wich is common for every data object. And additionally it requires code behind file:</p>
<pre class="brush: csharp;">
    public partial class GenericGridView : UserControl
    {
        public GenericGridView()
        {
            InitializeComponent();

            Loaded += GenericGridView_Loaded;
        }

        void GenericGridView_Loaded(object sender, RoutedEventArgs e)
        {
            ConfigureGrid();
        }

        private void ConfigureGrid()
        {
            IGridConfiguator c = DataContext as IGridConfiguator;
            if (c != null)
            {
                GridWithData.AutoGenerateColumns = false;
                c.Configure(GridWithData);
            }
            else
            {
                GridWithData.AutoGenerateColumns = true;
            }
        }
    }
</pre>
<p>Of course Configure function should be implemented in concrete class eg. PersonGridViewModel:</p>
<pre class="brush: csharp;">
    [NotifyPropertyChanged]
    public class PersonGridViewModel : GridController
    {
        public PersonGridViewModel()
        {
            m_CurrentType = typeof(PersonForGrid);
            GridData = new ObservableCollection&lt;PersonForGrid&gt;();
        }

        public override void Configure(DataGrid gridToConfigure)
        {
            gridToConfigure.Columns.Add(
                new DataGridTextColumn()
                {
                    Header = &quot;First name&quot;,
                    IsReadOnly = true,
                    Binding = new Binding(PersonForGrid.FIRSTNAME)
                });
            gridToConfigure.Columns.Add(
                new DataGridTextColumn()
                {
                    Header = &quot;Surename&quot;,
                    IsReadOnly = true,
                    Binding = new Binding(PersonForGrid.LASTNAME)
                });
            gridToConfigure.Columns.Add(
                new DataGridTextColumn()
                {
                    Header = &quot;Birth date&quot;,
                    IsReadOnly = true,
                    Binding = new Binding(PersonForGrid.BIRTHDATY)
                    {
                        StringFormat = &quot;d&quot;
                    }
                });
        }
    }
</pre>
<p>Actually that solution fits me, but probably it not the last word <img src='http://s2.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/42/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/42/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/42/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=42&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/02/23/generic-grid-view/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
		<item>
		<title>WPF irritations and solutions</title>
		<link>http://bezieur.wordpress.com/2009/02/22/wpf-irritations-and-solutions/</link>
		<comments>http://bezieur.wordpress.com/2009/02/22/wpf-irritations-and-solutions/#comments</comments>
		<pubDate>Sun, 22 Feb 2009 12:01:14 +0000</pubDate>
		<dc:creator>bezieur</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://bezieur.wordpress.com/?p=39</guid>
		<description><![CDATA[The first is ICommand, why on earth we are obliged to repeat relaying command wrappers? I personally hate to repeat the same code all over. The same thing is with INotifyPropertyChanged. And my cure for that: caliburn, which basically eliminate need of ICommands all over, and Postsharp, which can help to implement INotifyPropertyChanged. I&#8217;ve found [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=39&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>The first is <strong>ICommand</strong>, why on earth we are obliged to repeat relaying command wrappers? I personally hate to repeat the same code all over. The same thing is with <strong>INotifyPropertyChanged</strong>.</p>
<p>And my cure for that: <a href="http://www.codeplex.com/caliburn">caliburn</a>, which basically eliminate need of ICommands all over, and <a href="http://www.postsharp.org/">Postsharp</a>, which can help to implement INotifyPropertyChanged. I&#8217;ve found that in Postsharp samples directory there is a INotifyPropertyChanged implementation, and is quite decent. (For a project of mine, I&#8217;ve just changed the code to intercept also private setters).</p>
<p>And my irritation has decreased.</p>
<p>One thing left: build ui with ioc.</p>
<p>And so my solution is to build view model classes with ioc, and they can expose some &#8220;configuration&#8221; classes for views. I&#8217;ll explain it detailed in next post.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/bezieur.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/bezieur.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/bezieur.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/bezieur.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/bezieur.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/bezieur.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/bezieur.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/bezieur.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bezieur.wordpress.com&amp;blog=6259978&amp;post=39&amp;subd=bezieur&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bezieur.wordpress.com/2009/02/22/wpf-irritations-and-solutions/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/5def1647c3488704c068c0610e8fe7fd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">bezieur</media:title>
		</media:content>
	</item>
	</channel>
</rss>
