<?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/"
	>

<channel>
	<title>Tim Van Wassenhove &#187; WPF</title>
	<atom:link href="http://www.timvw.be/category/information-technology/windows-presentation-foundation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.timvw.be</link>
	<description>The journey of a thousand miles begins with one step.</description>
	<lastBuildDate>Thu, 29 Jul 2010 17:07:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Couple of methods missing on ObservableCollection</title>
		<link>http://www.timvw.be/couple-of-methods-missing-on-observablecollection/</link>
		<comments>http://www.timvw.be/couple-of-methods-missing-on-observablecollection/#comments</comments>
		<pubDate>Fri, 06 Nov 2009 15:42:40 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1512</guid>
		<description><![CDATA[Here are a couple of methods that are missing on ObservableCollection&#60;T&#62;: public static class ObservableCollectionExtensions { public static void AddRange&#60;T&#62;(this ObservableCollection&#60;T&#62; observableCollection, IEnumerable&#60;T&#62; elements) { foreach (var element in elements) observableCollection.Add(element); } public static ObservableCollection&#60;T&#62; Create&#60;T&#62;(IEnumerable&#60;T&#62; elements) { var observableCollection = new ObservableCollection&#60;T&#62;(); observableCollection.AddRange(elements); return observableCollection; } }]]></description>
			<content:encoded><![CDATA[<p>Here are a couple of methods that are missing on <a href="http://msdn.microsoft.com/en-us/library/ms668604.aspx">ObservableCollection&lt;T&gt;</a>:</p>

<pre class="brush: csharp;">public static class ObservableCollectionExtensions
{
 public static void AddRange&lt;T&gt;(this ObservableCollection&lt;T&gt; observableCollection, IEnumerable&lt;T&gt; elements)
 {
  foreach (var element in elements) observableCollection.Add(element);
 }

 public static ObservableCollection&lt;T&gt; Create&lt;T&gt;(IEnumerable&lt;T&gt; elements)
 {
  var observableCollection = new ObservableCollection&lt;T&gt;();
  observableCollection.AddRange(elements);
  return observableCollection;
 }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/couple-of-methods-missing-on-observablecollection/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring graphical programming with Blend, Visual State Manager and Behaviors</title>
		<link>http://www.timvw.be/exploring-graphical-programming-with-blend-visual-state-manager-and-behaviors/</link>
		<comments>http://www.timvw.be/exploring-graphical-programming-with-blend-visual-state-manager-and-behaviors/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 20:37:21 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1437</guid>
		<description><![CDATA[A while ago i presented the ControlStateMachine and in Silverlight this concept is implemented as the Visual State Manager. In my sokoban implementation i have a cellview which exists out of 6 canvasses but only two of them (one for the cell type and one for the piece type) are visible at any given point [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago i presented the <a href="http://www.timvw.be/experimenting-with-controlstatemachine-and-fluent-interfaces/">ControlStateMachine</a> and in Silverlight this concept is implemented as the <a href="http://windowsclient.net/wpf/wpf35/wpf-35sp1-toolkit-visual-state-manager-overview.aspx">Visual State Manager</a>.</p>

<p>In my sokoban implementation i have a cellview which exists out of 6 canvasses but only two of them (one for the cell type and one for the piece type) are visible at any given point in time. I have implemented this with 6 properties CanvasXVisible (with X being Player, Box, Wall, Goal, Floor and Cell) in my ViewModel but a State Machine / Manager may help clarify how the visibility of the canvasses are related. Here are the 2 visual state groups and their states that i would need for the CellView:</p>

<img src="http://www.timvw.be/wp-content/images/cellview-vsm.png" alt="screenshot of visual state manager in expression blend" />

<p>As you can see there is quite a lof of XAML involved to make the correct canvas visible:</p>

<pre class="brush: xml;">
 &lt;Storyboard&gt;
  &lt;ObjectAnimationUsingKeyFrames BeginTime=&quot;00:00:00&quot;  Duration=&quot;00:00:00.0010000&quot; 
   Storyboard.TargetName=&quot;Space&quot;  Storyboard.TargetProperty=&quot;(UIElement.Visibility)&quot;&gt;
    &lt;DiscreteObjectKeyFrame KeyTime=&quot;00:00:00&quot;&gt;
     &lt;DiscreteObjectKeyFrame.Value&gt;
      &lt;Visibility&gt;Visible&lt;/Visibility&gt;
     &lt;/DiscreteObjectKeyFrame.Value&gt;
    &lt;/DiscreteObjectKeyFrame&gt;
   &lt;/ObjectAnimationUsingKeyFrames&gt;
  &lt;/Storyboard&gt;
&lt;/VisualState&gt;</pre>

<p>For a simple modification to the Visibility property this seems like overkill but in many situations you will want to change more than this one property.</p>

<p>With the aid of the behaviors that come with Blend i can quickly add a couple of radio buttons, toss in some gotostate actions and end up with an interactive application:</p>

<img src="http://www.timvw.be/wp-content/images/gotostateaction.png" alt="screenshot of gotostate action properties" />

<pre class="brush: xml;">
 &lt;i:Interaction.Triggers&gt;
  &lt;i:EventTrigger EventName=&quot;Checked&quot;&gt;
   &lt;ic:GoToStateAction StateName=&quot;Wall1&quot;/&gt;
  &lt;/i:EventTrigger&gt;
 &lt;/i:Interaction.Triggers&gt;
&lt;/RadioButton&gt;</pre>

<p>Feel free to try it yourself by changing the radio buttons:</p>

<div id="exploringVSM">
 <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"  width="300" height="240">
  <param name="source" value="http://www.timvw.be/ClientBin/ExploringVSM.xap"/>
  <param name="onError" value="onSilverlightError" />
  <param name="background" value="white" />
  <param name="minRuntimeVersion" value="3.0.40624.0" />
  <param name="autoUpgrade" value="true" />
  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none">
   <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
  </a>
 </object>
 <iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div></div>

<p>Conclusion: All in all it is relatively easy to create interactive applications using Blend without writing a single line of code. Too bad that the behaviors are in an Expression assembly and don&#8217;t come with standard Silverlight. Another attention point is the maintainability of this new style of programming.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/exploring-graphical-programming-with-blend-visual-state-manager-and-behaviors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ViewModel to translate domain messages to view events</title>
		<link>http://www.timvw.be/viewmodel-to-translate-domain-messages-to-view-events/</link>
		<comments>http://www.timvw.be/viewmodel-to-translate-domain-messages-to-view-events/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 16:18:16 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1430</guid>
		<description><![CDATA[Here is an example of a ViewModel that translates domain messages to view events: class GameViewModel : INotifyPropertyChanged, IListener&#60;BoardChanged&#62; { public event PropertyChangedEventHandler PropertyChanged = delegate { }; public GameViewModel() { var messageBus = ServiceLocator.MessageBus; messageBus.Subscribe&#60;BoardChanged&#62;(this); } void IListener&#60;BoardChanged&#62;.Handle(BoardChanged message) { PropertyChanged(&#34;Board&#34;); } }]]></description>
			<content:encoded><![CDATA[<p>Here is an example of a ViewModel that translates domain messages to view events:</p>

<pre class="brush: csharp;">class GameViewModel : INotifyPropertyChanged, IListener&lt;BoardChanged&gt;
{
 public event PropertyChangedEventHandler PropertyChanged = delegate { }; 

 public GameViewModel()
 {
  var messageBus = ServiceLocator.MessageBus;
  messageBus.Subscribe&lt;BoardChanged&gt;(this);
 }

 void IListener&lt;BoardChanged&gt;.Handle(BoardChanged message)
 {
  PropertyChanged(&quot;Board&quot;);
 }
}</pre>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/viewmodel-to-translate-domain-messages-to-view-events/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About databinding and composite views</title>
		<link>http://www.timvw.be/about-databinding-and-composite-views/</link>
		<comments>http://www.timvw.be/about-databinding-and-composite-views/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 15:44:43 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1417</guid>
		<description><![CDATA[A couple of days ago i had a databound ItemsControl (collection of Model.Cell) which instantiated sub views (with their own viewmodel). &#60;Grid.Resources&#62; &#60;DataTemplate x:Key=&#34;CellTemplate&#34;&#62; &#60;views:CellView /&#62; &#60;/DataTemplate&#62; &#60;/Grid.Resources&#62; &#60;ItemsControl ItemTemplate=&#34;{StaticResource CellTemplate}&#34; ItemsSource=&#34;{Binding Cells}&#34; /&#62; &#60;/Grid&#62; Because each CellViewModel needs to know which cell they manage i used the following dirty hack: public CellView() { Loaded [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of days ago i had a databound ItemsControl (collection of Model.Cell) which instantiated sub views (with their own viewmodel).</p>

<pre class="brush: xml;">
 &lt;Grid.Resources&gt;
  &lt;DataTemplate x:Key=&quot;CellTemplate&quot;&gt;
   &lt;views:CellView /&gt;
  &lt;/DataTemplate&gt;
 &lt;/Grid.Resources&gt;
 &lt;ItemsControl 
   ItemTemplate=&quot;{StaticResource CellTemplate}&quot; 
   ItemsSource=&quot;{Binding Cells}&quot; /&gt;
&lt;/Grid&gt;</pre> 

<p>Because each CellViewModel needs to know which cell they manage i used the following dirty hack:</p>

<pre class="brush: csharp;">public CellView() 
{
 Loaded += CellView_Loaded; 
}

void CellView_Loaded(object sender, RoutedEventArgs e) 
{
 DataContext = new CellViewModel(DataContext);
}</pre>

<p>Later on that day i realised there was a much cleaner solution: Let the BoardViewModel expose a collection of ViewModels.CellViewModel instead of Model.Cell. What a relief that i don&#8217;t have to use the Loaded event hack <img src='http://www.timvw.be/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/about-databinding-and-composite-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring M-V-VM</title>
		<link>http://www.timvw.be/exploring-m-v-vm/</link>
		<comments>http://www.timvw.be/exploring-m-v-vm/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 15:10:10 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1403</guid>
		<description><![CDATA[A couple of years ago a collegue recommended Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET and i noticed that my code started to gravitate towards an Model-View-ViewModel architecture. Due to shortcomings and painful experiences i gave up on databinding and began to use Passieve View instead. Passive View doesn&#8217;t [...]]]></description>
			<content:encoded><![CDATA[<p>A couple of years ago a collegue recommended <a href="http://www.amazon.com/Data-Binding-Windows-Forms-2-0/dp/032126892X">Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET</a> and i noticed that my code started to gravitate towards an <a href="http://en.wikipedia.org/wiki/Model_View_ViewModel">Model-View-ViewModel</a> architecture. Due to shortcomings and painful experiences i gave up on databinding and began to use <a href="http://martinfowler.com/eaaDev/PassiveScreen.html">Passieve View</a> instead.</p>

<p>Passive View doesn&#8217;t work (well) with smart views so i decided to give M-V-VM another because i really wanted to leverage WPF&#8217;s rich support for databinding.</p>

<p>The key difference between M-V-VM and Passive View is, imho, the fact that the ViewModel is unaware of the View unlike Passive View where the Presenter knows about the (simple) View.</p>

<p>When we test a Presenter i notice that we end up writing interaction based tests (assertions on a mocked view) and when we test a ViewModel we end up writing state-based tests instead.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/exploring-m-v-vm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sokoban: Creating graphics with Expression Design</title>
		<link>http://www.timvw.be/sokoban-creating-graphics-with-expression-design/</link>
		<comments>http://www.timvw.be/sokoban-creating-graphics-with-expression-design/#comments</comments>
		<pubDate>Mon, 12 Oct 2009 08:32:37 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1393</guid>
		<description><![CDATA[Earlier this morning i decided to improve the graphics the little. I launched Expression Design, created a new image, and drew each possible cell and piece in a seperate layer. With this technique i can easily preview how a &#8220;Box&#8221; on &#8220;Goal&#8221; looks like. For each layer i simply copied the XAML from Expression Design [...]]]></description>
			<content:encoded><![CDATA[<p>Earlier this morning i decided to improve the graphics the little. I launched Expression Design, created a new image, and drew each possible cell and piece in a seperate layer. With this technique i can easily preview how a &#8220;Box&#8221; on &#8220;Goal&#8221; looks like.</p>

<p>For each layer i simply copied the XAML from Expression Design into my Cell.xaml file. Apparently all the layers are interpreted as a Canvas and the layer name determines their x:Name which makes it pretty easy to make the correct canvasses visible. With a simple ScaleTransform i can ensure that the canvasses are sized correctly.</p>

<p>Here is the updated version of Sokoban:</p>

<div id="silverlightControlHost2">
 <object data="data:application/x-silverlight-2," type="application/x-silverlight-2"  width="850" height="400">
  <param name="source" value="http://www.timvw.be/ClientBin/Sokoban2.xap"/>
  <param name="onError" value="onSilverlightError" />
  <param name="background" value="white" />
  <param name="minRuntimeVersion" value="3.0.40624.0" />
  <param name="autoUpgrade" value="true" />
  <a href="http://go.microsoft.com/fwlink/?LinkID=149156&#038;v=3.0.40624.0" style="text-decoration:none">
   <img src="http://go.microsoft.com/fwlink/?LinkId=108181" alt="Get Microsoft Silverlight" style="border-style:none"/>
  </a>
 </object>
 <iframe id="_sl_historyFrame" style="visibility:hidden;height:0px;width:0px;border:0px"></iframe>
</div>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/sokoban-creating-graphics-with-expression-design/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Silverlight wishlist</title>
		<link>http://www.timvw.be/silverlight-wishlist/</link>
		<comments>http://www.timvw.be/silverlight-wishlist/#comments</comments>
		<pubDate>Sat, 10 Oct 2009 05:52:26 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[Silverlight]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1354</guid>
		<description><![CDATA[Here are the features that i would love to see in Silverlight: Allow users to copy text from the UI (Or was the UX argument an excuse for playing with new toys?) MSTEST (I know that Silverlight Unit Test Framework exists.) Triggers (including data triggers) Typed data templates Uniform XAML (WPF: &#60;Style TargetType={x:Type local:Foo}/&#62; vs [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the features that i would love to see in Silverlight:</p>

<ul>
<li>Allow users to copy text from the UI (Or was the UX argument an excuse for playing with new toys?)</li>
<li>MSTEST (I know that <a href="http://code.msdn.microsoft.com/silverlightut/">Silverlight Unit Test Framework </a> exists.)</li>
<li>Triggers (including data triggers)</li>
<li>Typed data templates</li>
<li>Uniform XAML (WPF: &lt;Style TargetType={x:Type local:Foo}/&gt; vs Silverlight: &lt;Style TargetType={local:Foo}/&gt;)</li>
<li>Uniform validation API (eg: Data Annotations has three flavors)</li>
<li>XAML with less namespaces (doesn&#8217;t really matter if you&#8217;re a designer only type)</li>
<li>Support for Desktop (&#8216;regular&#8217;) .NET assemblies. As long as Desktop .NET assemblies are not supported, tools that automate the process of generating a &#8216;shadow&#8217; .Silverlight project (eg: Prism has for each project a silverlight project that, ignoring the different assembly references, exists out of file references to the orginal project).</li>
<li>UniformGrid</li>
</ul>

<p>Note: This list is not exhaustive and may change in the future.</p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/silverlight-wishlist/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>About Expression Blend</title>
		<link>http://www.timvw.be/about-expression-blend/</link>
		<comments>http://www.timvw.be/about-expression-blend/#comments</comments>
		<pubDate>Mon, 05 Oct 2009 12:08:39 +0000</pubDate>
		<dc:creator>timvw</dc:creator>
				<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://www.timvw.be/?p=1301</guid>
		<description><![CDATA[At first i developed most WPF interfaces by writing XAML in the code view of Visual Studio. Those days are gone These days i find it a lot easier to use Expression Blend (eg: paths, animations and timelines) but i reallly don&#8217;t like it that Blend adds design-time information to the XAML that is intended [...]]]></description>
			<content:encoded><![CDATA[<p>At first i developed most WPF interfaces by writing XAML in the code view of Visual Studio. Those days are gone <img src='http://www.timvw.be/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  These days i find it a lot easier to use Expression Blend (eg: paths, animations and timelines) but i reallly don&#8217;t like it that Blend adds design-time information to the XAML that is intended to be used in production code. A tool should not add clutter to your code!</p>

<p>I also dislike the fact that Blend adds values for Width and Height to each element by default. This requires me to hit that &#8216;auto&#8217; square in the properties window for each element. What a waste of time <img src='http://www.timvw.be/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>]]></content:encoded>
			<wfw:commentRss>http://www.timvw.be/about-expression-blend/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
