<?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>michlG&#039;s Blog</title>
	<atom:link href="http://michlg.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://michlg.wordpress.com</link>
	<description></description>
	<lastBuildDate>Mon, 19 Dec 2011 17:22:28 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='michlg.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>michlG&#039;s Blog</title>
		<link>http://michlg.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://michlg.wordpress.com/osd.xml" title="michlG&#039;s Blog" />
	<atom:link rel='hub' href='http://michlg.wordpress.com/?pushpress=hub'/>
		<item>
		<title>WPF MouseDown / MouseUp Command</title>
		<link>http://michlg.wordpress.com/2011/02/04/wpf-mousedown-mouseup-command/</link>
		<comments>http://michlg.wordpress.com/2011/02/04/wpf-mousedown-mouseup-command/#comments</comments>
		<pubDate>Fri, 04 Feb 2011 22:11:12 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[WPF]]></category>
		<category><![CDATA[Behavior]]></category>
		<category><![CDATA[Button]]></category>
		<category><![CDATA[Command]]></category>
		<category><![CDATA[Mouse]]></category>
		<category><![CDATA[MVVM]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=279</guid>
		<description><![CDATA[Maybe you wanted to bind a command to the MouseDown Event of the Button. But there is just the Command for the Click Event. Therefore it is necessary to do a little bit of coding. I usually need the MouseDown / MouseUp Events of the Button for several use cases. Therefore I just created a <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=279&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Maybe you wanted to bind a command to the MouseDown Event of the Button.<br />
But there is just the Command for the Click Event. Therefore it is necessary to do a little bit of coding.</p>
<p>I usually need the MouseDown / MouseUp Events of the Button for several use cases.<br />
Therefore I just created a simple behavior which contains two command properties (on for the MouseUp and one for the MouseDown event).</p>
<p>The MouseCommandBehavior class looks like this</p>
<p><pre class="brush: csharp;">
public static class MouseCommandBehavior
  {
    #region Commands

    ///
    /// The comamnd which should be executed when the mouse is down
    ///
    public static readonly DependencyProperty MouseDownCommandProperty =
        DependencyProperty.RegisterAttached(&quot;MouseDownCommand&quot;,
            typeof(ICommand),
            typeof(MouseCommandBehavior),
            new FrameworkPropertyMetadata(null, (obj, e) =&gt; OnMouseCommandChanged(obj, (ICommand)e.NewValue, false)));

    ///
    /// Gets the MouseDownCommand property
    ///
    public static ICommand GetMouseDownCommand(DependencyObject d)
    {
      return (ICommand)d.GetValue(MouseDownCommandProperty);
    }

    ///
    /// Sets the MouseDownCommand property
    ///
    public static void SetMouseDownCommand(DependencyObject d, ICommand value)
    {
      d.SetValue(MouseDownCommandProperty, value);
    }

    ///
    /// The comamnd which should be executed when the mouse is up
    ///
    public static readonly DependencyProperty MouseUpCommandProperty =
        DependencyProperty.RegisterAttached(&quot;MouseUpCommand&quot;,
            typeof(ICommand),
            typeof(MouseCommandBehavior),
            new FrameworkPropertyMetadata(null, new PropertyChangedCallback((obj, e) =&gt; OnMouseCommandChanged(obj, (ICommand)e.NewValue, true))));

    ///
    /// Gets the MouseUpCommand property
    ///
    public static ICommand GetMouseUpCommand(DependencyObject d)
    {
      return (ICommand)d.GetValue(MouseUpCommandProperty);
    }

    ///
    /// Sets the MouseUpCommand property
    ///
    public static void SetMouseUpCommand(DependencyObject d, ICommand value)
    {
      d.SetValue(MouseUpCommandProperty, value);
    }

    #endregion

    ///
    /// Registeres the event and calls the command when it gets fired
    ///
    private static void OnMouseCommandChanged(DependencyObject d, ICommand command, bool isMouseUp)
    {
      if (command == null) return;

      var element = (FrameworkElement)d;

      if(isMouseUp)
          element.PreviewMouseUp += (obj, e) =&gt; command.Execute(null);
      else
          element.PreviewMouseDown += (obj, e) =&gt; command.Execute(null);
      }
    }
  }
</pre></p>
<p>I hardcoded in this class these two events. But you could even add your own ones <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In the XAML-Code you can use it like that</p>
<p><pre class="brush: xml;">
        &lt;button&gt;
</pre></p>
<p></button></pre>
<p>If you want a even more flexible approach where you can register just one Command then you can use the behavior of Sacha Barber.<br />
Check this out <a href="http://sachabarber.net/?p=514">WPF : Attached Commands</a></p>
<p>I attached a zip file (remove the .doc extension) which contains a complete project. It is slightly different then what I explained above but the idea is the same.</p>
<p><a href="http://michlg.files.wordpress.com/2011/02/wpfapplication2-zip.doc">WpfApplication2.zip</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/279/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/279/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/279/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=279&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2011/02/04/wpf-mousedown-mouseup-command/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>Task Parallel Library (Tasks) and the GUI thread</title>
		<link>http://michlg.wordpress.com/2010/12/20/task-parallel-library-tasks-and-the-gui-thread/</link>
		<comments>http://michlg.wordpress.com/2010/12/20/task-parallel-library-tasks-and-the-gui-thread/#comments</comments>
		<pubDate>Mon, 20 Dec 2010 19:50:11 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=272</guid>
		<description><![CDATA[With .Net 4 we have a very nice feature called the task parallel library. Especially in long running applications (like database accesses, mathematical computations&#8230;) you have to run them on a different thread. Before .Net 4 we either used the BackgroundWorker or a Thread (from the ThreadPool). In the good old days we have even <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=272&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>With .Net 4 we have a very nice feature called the <a href="http://msdn.microsoft.com/de-de/library/dd460717.aspx">task parallel library</a>.<br />
Especially in long running applications (like database accesses, mathematical computations&#8230;) you have to run them on a different thread.</p>
<p>Before .Net 4 we either used the BackgroundWorker or a Thread (from the ThreadPool).</p>
<p>In the good old days we have even been happy with them but when you see the new tasks then you will not like them anymore <img src='http://s1.wp.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /><br />
With the tasks you can do much more than just running a piece of code in a worker thread but it does not guarantee that the task is not run in the GUI thread.</p>
<p>If that happens it can block the application which could be really annoying for us and also for the user.</p>
<p>In order to guarantee that the task is run in a non GUI thread we have to build our own TaskScheduler.<br />
In the samples for the parallel programming with .net 4 is already a custom TaskScheduler (called StaTaskScheduler) <a href="http://code.msdn.microsoft.com/ParExtSamples">http://code.msdn.microsoft.com/ParExtSamples</a></p>
<p>Usually you start your task like in this example</p>
<p><pre class="brush: csharp;">Task.Factory.StartNew(() =&gt; DoLongRunningOperation());</pre></p>
<p>If you want to use the custom TaskScheduler (called StaTaskScheduler) then you have to start the task like in the following example</p>
<p><pre class="brush: csharp;">var scheduler = new StaTaskScheduler(5);
Task.Factory.StartNew(() =&gt; DoLongRunningOperation(),
                                        CancellationToken.None,
                                        TaskCreationOptions.None,
                                        scheduler);
</pre></p>
<p>Now we have a way in which we can be sure that our tasks are not run in the GUI thread.</p>
<p>With the number (5 in my example) we can define how much threads should be used by the TaskScheduler to execute our actions.</p>
<p>If there are not enough threads (ex. if we have 5 tasks and just 2 threads) then the tasks will automatically wait until a thread is free.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/272/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/272/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/272/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=272&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/12/20/task-parallel-library-tasks-and-the-gui-thread/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>The type reference cannot find a public type named ‘MyType’</title>
		<link>http://michlg.wordpress.com/2010/09/07/the-type-reference-cannot-find-a-public-type-named-%e2%80%98mytype%e2%80%99/</link>
		<comments>http://michlg.wordpress.com/2010/09/07/the-type-reference-cannot-find-a-public-type-named-%e2%80%98mytype%e2%80%99/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 20:46:22 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[DataTemplate]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=260</guid>
		<description><![CDATA[Today I had a strange problem when I wanted to define a DataTemplate of a specific type which is located in the same assembly as I wanted to use it. The problem was that if I wrote the assembly-name in the import of the Namespace then I got the following Exception: The type reference cannot <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=260&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Today I had a strange problem when I wanted to define a DataTemplate of a specific type which is located in the same assembly as I wanted to use it.<br />
The problem was that if I wrote the assembly-name in the import of the Namespace then I got the following Exception:</p>
<p><strong>The type reference cannot find a public type named ‘MyType’</strong></p>
<p>So after a few hours of testing and searching I finally found the solution. I just had to remove the assembly from the import of the namespace.</p>
<p>Now lets have a look at a simple demonstration of the problem</p>
<p>This is the type I want to assign to the DataTemplate<br />
<pre class="brush: csharp;">
namespace MyWpfApp
{
    public class MyType
    {
        private string _description;

        public MyType(string description)
        {
            _description= description;
        }

        public string Description
        {
            get { return _description; }
        }
    }
}
</pre></p>
<p>In the UI I defined a DataTemplate for this type<br />
<pre class="brush: xml;">
&lt;Window x:Class=&quot;MyWpfApp.MainWindow&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:me=&quot;clr-namespace:MyWpfApp;assembly=MyWpfApp&quot;
    Title=&quot;MainWindow&quot;&gt;    
    &lt;Window.Resources&gt;
        &lt;DataTemplate DataType=&quot;{x:Type me:MyType}&quot;&gt; &lt;!-- Here it displays the error message --&gt;
            &lt;StackPanel Orientation=&quot;Vertical&quot;&gt;
                &lt;TextBlock Text=&quot;Description&quot; FontWeight=&quot;Bold&quot; Margin=&quot;5&quot;/&gt;
                &lt;TextBlock Text=&quot;{Binding Description}&quot; Margin=&quot;5&quot;/&gt;
            &lt;/StackPanel&gt;
        &lt;/DataTemplate&gt;
......
</pre></p>
<p>This code results in the error message I talked about before.</p>
<p>But if you change the import of the MyWpfApp namespace then it works without problems.<br />
<pre class="brush: xml;">
&lt;Window x:Class=&quot;MyWpfApp.MainWindow&quot;
    xmlns=&quot;http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
    xmlns:x=&quot;http://schemas.microsoft.com/winfx/2006/xaml&quot;
    xmlns:me=&quot;clr-namespace:MyWpfApp&quot; &lt;!-- REMOVED the assembly in the namespace import to fix the problem --&gt;
    Title=&quot;MainWindow&quot;&gt;    
    &lt;Window.Resources&gt;
        &lt;DataTemplate DataType=&quot;{x:Type me:MyType}&quot;&gt;
            &lt;StackPanel Orientation=&quot;Vertical&quot;&gt;
                &lt;TextBlock Text=&quot;Description&quot; FontWeight=&quot;Bold&quot; Margin=&quot;5&quot;/&gt;
                &lt;TextBlock Text=&quot;{Binding Description}&quot; Margin=&quot;5&quot;/&gt;
            &lt;/StackPanel&gt;
        &lt;/DataTemplate&gt;
......
</pre></p>
<p>Have fun</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/260/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/260/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/260/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=260&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/09/07/the-type-reference-cannot-find-a-public-type-named-%e2%80%98mytype%e2%80%99/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>.NET Framework Offline Installers</title>
		<link>http://michlg.wordpress.com/2010/08/30/net-framework-offline-installers/</link>
		<comments>http://michlg.wordpress.com/2010/08/30/net-framework-offline-installers/#comments</comments>
		<pubDate>Mon, 30 Aug 2010 18:38:19 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[offline installer]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=256</guid>
		<description><![CDATA[A few days ago I had to install my .NET program on a PC without internet connection. The problem was that more than 99% of the links regarding the .NET framework are these online installers. But I found a wonderful blog post which contains the links to offline installers of all framework version. Here it <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=256&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>A few days ago I had to install my .NET program on a PC without internet connection.<br />
The problem was that more than 99% of the links regarding the .NET framework are these online installers.</p>
<p>But I found a wonderful blog post which contains the links to offline installers of all framework version.<br />
Here it is: <a href="http://www.techdreams.org/microsoft/download-offline-installers-of-net-framework-35-35-sp1-30-20-from-microsoft-servers/1845-20090314">.NET offline installers</a></p>
<p>Have fun!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/256/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/256/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/256/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=256&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/08/30/net-framework-offline-installers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>How to create a generic list using reflection</title>
		<link>http://michlg.wordpress.com/2010/07/17/how-to-create-a-generic-list-using-reflection/</link>
		<comments>http://michlg.wordpress.com/2010/07/17/how-to-create-a-generic-list-using-reflection/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 14:06:13 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[Generics]]></category>
		<category><![CDATA[List]]></category>
		<category><![CDATA[Reflection]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=250</guid>
		<description><![CDATA[Reflection is a very powerful feature which allows you to do lots of crazy things. But sometimes you want to create a generic class which can be really annoying if you dont know how to do it. If you try to do it as usual then you will receive an exception. An example would be <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=250&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Reflection is a very powerful feature which allows you to do lots of crazy things.<br />
But sometimes you want to create a generic class which can be really annoying if you dont know how to do it.</p>
<p>If you try to do it as usual then you will receive an exception.<br />
An example would be</p>
<p><pre class="brush: csharp;">
var myType = typeof (double);
var list = (List&lt;myType&gt;) Activator.CreateInstance(typeof (List&lt;myType&gt;), null);
</pre></p>
<p>The compiler tells you that a type or namespace is expected and not myType!</p>
<p>&nbsp;</p>
<p>In order to do that you can use the MakeGenericType method to add the generic types to the List and after that you can create the instance</p>
<p><pre class="brush: csharp;">
var myGenericType = typeof(List&lt;&gt;).MakeGenericType(new []{typeof(double)});
var myList = (List&lt;double&gt;)Activator.CreateInstance(myGenericType);
</pre></p>
<p>Note that the MakeGenericType method only creates the type which then is used to create an object in the next line</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/250/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/250/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/250/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=250&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/07/17/how-to-create-a-generic-list-using-reflection/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>Extension Methods</title>
		<link>http://michlg.wordpress.com/2010/07/13/extension-methods/</link>
		<comments>http://michlg.wordpress.com/2010/07/13/extension-methods/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 13:00:15 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Dispachter]]></category>
		<category><![CDATA[Event]]></category>
		<category><![CDATA[Extension Methods]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=246</guid>
		<description><![CDATA[Extension Methods are a nice way to add some extra functionality to a already existing class. I use them for several tasks which are needed quite often. Such as the &#8220;raising&#8221; of an event or just the running of an action in the correct thread. Therefore I decided to post the most important Extension Methods <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=246&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Extension Methods are a nice way to add some extra functionality to a already existing class.<br />
I use them for several tasks which are needed quite often. Such as the &#8220;raising&#8221; of an event or just the running of an action in the correct thread.<br />
Therefore I decided to post the most important Extension Methods here.</p>
<p>When &#8220;raising&#8221; (fire) an event it is really annoying that we always have to check if the event is not null.<br />
This results in a quite long code and we have always to repeat the same thing again.</p>
<p>Example:<br />
<pre class="brush: csharp;">
public event EventHandler&lt;EventArgs&gt; MyEvent;

protected void RaiseMyEvent()
{
   if(MyEvent != null)
      MyEvent(this, EventArgs.Empty);
}
</pre></p>
<p>Using this extension method<br />
<pre class="brush: csharp;">
/// &lt;summary&gt;
/// This method raises the given event with the given sender and EventArgs
/// &lt;/summary&gt;
/// &lt;typeparam name=&quot;T&quot;&gt;The type of the event handler&lt;/typeparam&gt;
/// &lt;param name=&quot;eventHandler&quot;&gt;The event handler&lt;/param&gt;
/// &lt;param name=&quot;sender&quot;&gt;The sender&lt;/param&gt;
/// &lt;param name=&quot;e&quot;&gt;The event args&lt;/param&gt;
public static void Raise&lt;T&gt;(this EventHandler&lt;T&gt; eventHandler, Object sender, T e) where T : EventArgs
{
	if (eventHandler != null)
	{
		eventHandler(sender, e);
	}
}
</pre></p>
<p>it is possible to raise the event with that<br />
<pre class="brush: csharp;">
public event EventHandler MyEvent&lt;EventArgs&gt;;

MyEvent.Raise(this, EventArgs.Empty);
</pre></p>
<p>Another example where Extension Methods are really useful is when you want to ensure that an action / function is executed in the right thread.<br />
Usually you have to check whether you actually are in the right thread and invoke if necessary.</p>
<p>example:<br />
<pre class="brush: csharp;">
public void MyMethod()
{
     if(myDispatcher.CheckAccess())
     {
        DoSomething();
     }
     else
     {
        myDispatcher.Invoke(new Action(MyMethod));
     }
}
</pre><br />
In order to reduce this &#8220;useless&#8221; code we can use the following extension method<br />
<pre class="brush: csharp;">
		/// &lt;summary&gt;
		/// This method automatically executes the given action in
		/// the correct thread.
		/// &lt;/summary&gt;
		/// &lt;param name=&quot;source&quot;&gt;The source of the method call&lt;/param&gt;
		/// &lt;param name=&quot;func&quot;&gt;The function which should be executed in the right thread&lt;/param&gt;
		public static void Dispatch(this Dispatcher source, Action func)
		{
			if (source.CheckAccess())
				func();
			else
				source.Invoke(func);
		}
</pre></p>
<p>And here an example how to call it<br />
<pre class="brush: csharp;">
myDispatcher.Dispatch(DoSomething);
</pre></p>
<p>More useful extension methods will follow&#8230;</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/246/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/246/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/246/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=246&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/07/13/extension-methods/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>[WPF] How to change the width of a Scrollbar (Scrollviewer)</title>
		<link>http://michlg.wordpress.com/2010/05/15/wpf-how-to-change-the-width-of-a-scrollbar-scrollviewer/</link>
		<comments>http://michlg.wordpress.com/2010/05/15/wpf-how-to-change-the-width-of-a-scrollbar-scrollviewer/#comments</comments>
		<pubDate>Sat, 15 May 2010 09:40:58 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[Resources]]></category>
		<category><![CDATA[Scrollbar]]></category>
		<category><![CDATA[Scrollviewer]]></category>
		<category><![CDATA[Style]]></category>
		<category><![CDATA[Width]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=241</guid>
		<description><![CDATA[If you are programming applications which should be used on a touch screen then you may have encountered the problem that it is tricky to use the scrollbar with the finger. Because the default scrollbar is to small. If you want to adjust the width of all scrollbars in your application you can put this <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=241&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are programming applications which should be used on a touch screen then you may have encountered the problem that it is tricky to use the scrollbar with the finger.<br />
Because the default scrollbar is to small.</p>
<p>If you want to adjust the width of all scrollbars in your application you can put this piece of code into you resources<br />
<pre class="brush: xml;">
        &lt;Style x:Key=&quot;{x:Type ScrollBar}&quot; TargetType=&quot;{x:Type ScrollBar}&quot;&gt;          
                &lt;Setter Property=&quot;MinWidth&quot; Value=&quot;35&quot; /&gt;
                &lt;Setter Property=&quot;Width&quot; Value=&quot;35&quot; /&gt;
        &lt;/Style&gt;
</pre></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/241/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/241/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/241/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=241&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/05/15/wpf-how-to-change-the-width-of-a-scrollbar-scrollviewer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>Visual Studio 2010 has been released</title>
		<link>http://michlg.wordpress.com/2010/04/12/visual-studio-2010-has-been-released/</link>
		<comments>http://michlg.wordpress.com/2010/04/12/visual-studio-2010-has-been-released/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 20:22:30 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=238</guid>
		<description><![CDATA[Hello everybody, Visual Studio 2010 has been released a few hours ago. You can download it here: I hope that it works at least as good as the 2010 <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=238&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello everybody,</p>
<p>Visual Studio 2010 has been released a few hours ago.<br />
You can download it here: <a href="http://www.microsoft.com/visualstudio/en-us/download"></p>
<p>I hope that it works at least as good as the 2010 RC <img src='http://s0.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/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/238/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/238/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/238/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=238&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/04/12/visual-studio-2010-has-been-released/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>[WPF] Custom ValidationRule with an additional parameter</title>
		<link>http://michlg.wordpress.com/2010/01/29/wpf-custom-validationrule-with-an-additional-parameter/</link>
		<comments>http://michlg.wordpress.com/2010/01/29/wpf-custom-validationrule-with-an-additional-parameter/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 21:43:19 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[CSharp]]></category>
		<category><![CDATA[DependencyProperty]]></category>
		<category><![CDATA[DotNet]]></category>
		<category><![CDATA[Proxy]]></category>
		<category><![CDATA[ValidationRule]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=232</guid>
		<description><![CDATA[Hello, maybe you ever had the problem that you wanted to create a custom validationrule but you need some kind of an extra parameter. But it seems that there is no straightforward way to do that. So I used this workaround in order to achieve that. In this example I will validate a string. The <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=232&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello,</p>
<p>maybe you ever had the problem that you wanted to create a custom validationrule but you need some kind of an extra parameter.<br />
But it seems that there is no straightforward way to do that.</p>
<p>So I used this workaround in order to achieve that.<br />
In this example I will validate a string. The parameter gives the length if the string is shorter then it is valid else not.</p>
<p>First of all we have to create our custom ValidationRule<br />
<pre class="brush: csharp;">
public class MyStringLengthValidationRule : ValidationRule
  {
    /// &lt;summary&gt;
    /// Gets or sets the maximal length of the string
    /// &lt;/summary&gt;
    public int Length { get; set; }

    /// &lt;summary&gt;
    /// Checks if the string is valied
    /// &lt;/summary&gt;
    public override ValidationResult Validate(object value, CultureInfo cultureInfo)
    {
      if (value.ToString().Length &lt;= Length)
         return new ValidationResult(true, null);
      return new ValidationResult(false, &quot;The string is to long&quot;);
    }
  }
</pre></p>
<p>All right. Here you see this simple ValidationRule with our additional property (Length).<br />
We can not use DependencyProperties because ValidationRule does not extend DependencyObject therefore we have to use this property.</p>
<p>The second step is to assign our ValidationRule to a control<br />
<pre class="brush: xml;">
        &lt;TextBox&gt;
            &lt;TextBox.Text&gt;
                &lt;Binding Path=&quot;MyText&quot;&gt;
                    &lt;Binding.ValidationRules&gt;
                        &lt;utils:MyStringLengthValidationRule Length=&quot;{Binding MyLength}&quot; /&gt;
                    &lt;/Binding.ValidationRules&gt;
                &lt;/Binding&gt;
            &lt;/TextBox.Text&gt;
        &lt;/TextBox&gt;
</pre><br />
You may think that it works like this but it does not. Since the Length property is not a DependencyProperty we can not directly bind to it.<br />
But there exists a nice workaround. We can just use a so-called proxy which allows us to bind values to normal properties.<br />
I used the proxy from this blog: http://www.11011.net/wpf-binding-properties</p>
<p>The version using the proxy looks like this<br />
<pre class="brush: xml;">
&lt;utils:Proxy In=&quot;{Binding MyLength, Mode=OneWay,UpdateSourceTrigger=PropertyChanged}&quot; Out=&quot;{Binding ElementName=strLengthValidationRule, Path=Length}&quot; /&gt; 
&lt;TextBox&gt;
  &lt;TextBox.Text&gt;
     &lt;Binding Path=&quot;MyText&quot;&gt;
         &lt;Binding.ValidationRules&gt;
            &lt;utils:MyStringLengthValidationRule x:Name=&quot;strLengthValidationRule&quot; /&gt;
          &lt;/Binding.ValidationRules&gt;
       &lt;/Binding&gt;
  &lt;/TextBox.Text&gt;
&lt;/TextBox&gt;
</pre></p>
<p>All right now it should work.</p>
<p>I attached the demo project. Where you can specify the maximal length (upper TextBox) of the string in the TextBox at the bottom.<br />
Note that the Validation will only be updated when the value of the TextBox was changed!</p>
<p>The attached file is a rar file. I just have to add the doc extension because else I can not upload it.<br />
Change the extension in .rar then you can extract it. (It contains the demo project as a VS 2010 Beta solution)<br />
<a href="http://michlG.files.wordpress.com/2010/01/validatorwithparameter-rar.doc">ValidatorWithParameter.rar (doc)</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/232/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/232/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/232/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=232&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/01/29/wpf-custom-validationrule-with-an-additional-parameter/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
		<item>
		<title>[WPF] Set Attached Properties (Grid.Column, Grid.Row, Canvas.Top, Canvas.Left, etc.) in C# Code</title>
		<link>http://michlg.wordpress.com/2010/01/23/wpf-set-attached-properties-grid-column-grid-row-canvas-top-canvas-left-in-c-code/</link>
		<comments>http://michlg.wordpress.com/2010/01/23/wpf-set-attached-properties-grid-column-grid-row-canvas-top-canvas-left-in-c-code/#comments</comments>
		<pubDate>Sat, 23 Jan 2010 15:37:17 +0000</pubDate>
		<dc:creator>michlG</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[WPF]]></category>
		<category><![CDATA[attached properties]]></category>
		<category><![CDATA[Codebehind]]></category>
		<category><![CDATA[CSharp]]></category>

		<guid isPermaLink="false">http://michlg.wordpress.com/?p=227</guid>
		<description><![CDATA[Hello everybody, if you tried to create a Grid, Canvas or a DockPanel in C# problem than you probably had the problem that you do not know how to add the children to a specific column, row or whatever. These properties are so called Attached Properties. And you can not see them if you call <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=227&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hello everybody,</p>
<p>if you tried to create a Grid, Canvas or a DockPanel in C# problem than you probably had the problem that you do not know how to add the children to a specific column, row or whatever.</p>
<p>These properties are so called Attached Properties. And you can not see them if you call textBox.Grid.Row in the C# code.</p>
<p>Here an example<br />
<pre class="brush: xml;">
&lt;Grid&gt;
   &lt;TextBox Grid.Row=&quot;0&quot; Grid.Column=&quot;0&quot; /&gt;
&lt;/Grid&gt;
</pre></p>
<p>But you can not do the following in your C# Code</p>
<p><span style="font-family:Consolas, Monaco, 'Courier New', Courier, monospace;line-height:18px;font-size:12px;white-space:pre;"> </span></p>
<p><pre class="brush: csharp;">
&lt;pre&gt;Grid grid = new Grid();
TextBox txt = new TextBox();
txt.Grid.Column = 1; //Not possible!
</pre></p>
<p>But you can do the following<br />
<pre class="brush: plain;">
//Set the Grid.Row Attached Property of the TextBox txt to 0
Grid.SetRow(txt, 0);
//Set the Grid.Column Attached Property of the TextBox txt to 0
Grid.SetColumn(txt,0);
</pre></p>
<p>It works in the same way for all other Attached Properties</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/michlg.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/michlg.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/michlg.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/michlg.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/michlg.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/michlg.wordpress.com/227/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/michlg.wordpress.com/227/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/michlg.wordpress.com/227/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=michlg.wordpress.com&amp;blog=8922334&amp;post=227&amp;subd=michlg&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://michlg.wordpress.com/2010/01/23/wpf-set-attached-properties-grid-column-grid-row-canvas-top-canvas-left-in-c-code/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/3e2c163486d4e1d957b21f7483e0925d?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">michlG</media:title>
		</media:content>
	</item>
	</channel>
</rss>
