<?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>dasz.at - Benutzbare Technologie &#187; WPF</title>
	<atom:link href="http://dasz.at/index.php/category/microsoft/wpf/feed/" rel="self" type="application/rss+xml" />
	<link>http://dasz.at</link>
	<description>Benutzbare Technologie</description>
	<lastBuildDate>Fri, 30 Jul 2010 17:07:19 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Attaching Events to ListViewItems in WPF</title>
		<link>http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/</link>
		<comments>http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/#comments</comments>
		<pubDate>Fri, 05 Jun 2009 12:13:35 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[StackOverflow]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/</guid>
		<description><![CDATA[I was looking for a way to attach a MouseDoubleClickHandler to the implicitly generated ListViewItems in a databound control:


&#60;ListView ItemsSource=&#34;{Binding Instances}&#34; /&#62;

For some strange reason all the mouse events seem to be directly routed instead of bubbling like other input events. Only some magic of the framework causes them to be raised for every hit [...]]]></description>
			<content:encoded><![CDATA[<p>I was looking for a way to attach a <a href="http://msdn.microsoft.com/en-us/library/system.windows.input.mousebuttoneventhandler.aspx">MouseDoubleClickHandler</a> to the implicitly generated ListViewItems in a databound control:</p>
<pre class="brush: xml; ">

&lt;ListView ItemsSource=&quot;{Binding Instances}&quot; /&gt;
</pre>
<p>For some strange reason all the mouse events seem to be directly routed instead of bubbling like other input events. Only some magic of the framework causes them to be raised for every hit control. This causes the <code>sender</code> to be totally worthless, since it is always the &#8220;current&#8221; object.</p>
<p><span id="more-84"></span> </p>
<p>Uncle Google just brought up a useless and wrong answer on the &#8220;site with a hyphen.&#8221; But after some fiddling I found the answer: just use an <code>EventSetter</code> to set the handler on all items:</p>
<pre class="brush: xml; ">

&lt;ListView ItemsSource=&quot;{Binding Instances}&quot; &gt;
    &lt;ListView.Resources&gt;
        &lt;Style TargetType=&quot;ListViewItem&quot;&gt;
            &lt;EventSetter Event=&quot;MouseDoubleClick&quot;
                Handler=&quot;OnDoubleClick&quot; /&gt;
        &lt;/Style&gt;
    &lt;/ListView.Resources&gt;
&lt;/ListView&gt;
</pre>
<p>Then I wanted to post the question and answer to <a href="http://stackoverflow.com">stackoverflow</a> so others can profit from it too. It turns out that this is an already solved problem: <a href="http://stackoverflow.com/questions/728205/wpf-listview-attaching-a-double-click-on-an-item-event">WPF ListView: Attaching a double-click (on an item) event</a>. Furthermore, both this page and the linked thread on the MSDN Forum were also available on the google results. Meh.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/06/attaching-events-to-listviewitems-in-wpf/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A quick sketch of asynchronous View Models</title>
		<link>http://dasz.at/index.php/2009/02/a-quick-sketch-of-asynchronous-view-models/</link>
		<comments>http://dasz.at/index.php/2009/02/a-quick-sketch-of-asynchronous-view-models/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 12:13:02 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2009/02/a-quick-sketch-of-asynchronous-view-models/</guid>
		<description><![CDATA[The How to make a loading graphic in WPF XAML? question on stackoverflow reminded me, that I wanted to write a short piece about the WPF infrastructure I&#8217;m currently writing. A first part was the Doing GUI architecture the Right Way where I describe the basic advantages of the View Model. Today I&#8217;m going to [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://stackoverflow.com/questions/473568/how-to-make-a-loading-graphic-in-wpf-xaml">How to make a loading graphic in WPF XAML?</a> question on <a href="http://stackoverflow.com">stackoverflow</a> reminded me, that I wanted to write a short piece about the WPF infrastructure I&#8217;m currently writing. A first part was the <a href="http://dasz.at/index.php/2008/11/doing-gui-architecture-the-right-way/">Doing GUI architecture the Right Way</a> where I describe the basic advantages of the View Model. Today I&#8217;m going to show some details of how this enables very smooth removal of background tasks from the UI Thread. Beware that this is work in progress, so edges might be rough.</p>
<p>The basic structure is three-fold: the Model where the actual data resides, the View which interacts with the user and the View Model as a intermediate layer. I will start out with describing the View, which is really thin. Afterwards I&#8217;ll talk a bit why the Model alone is not enough. In the last part I&#8217;ll describe my approach to filling the gap.</p>
<p><span id="more-77"></span></p>
<h3>The View</h3>
<p>The easiest part is the View. In WPF, this is the easiest part:</p>
<pre class="brush: xml; ">

&lt;Window ... DataContext=&quot;{StaticResource unitOfWork}&quot;&gt;
  &lt;ContentPresenter
    Content=&quot;{Binding}&quot;
    ContentTemplateSelector=&quot;{StaticResource defaultTemplateSelector}&quot; /&gt;
&lt;/Window&gt;
</pre>
<p>The <code>unitOfWork</code> is the root object of the current View Model tree and the <code>defaultTemplateSelector</code> uses meta data to map from a View Model class to the appropriate WPF template. In my case, this is coming from the bowels of the database but you can also just graft XAML (directly or by reference) onto the View Model.</p>
<p>Everything else in the View is done by binding to parts of the View Model and choosing the right template, either by way of the default template selector or overriding it when a special context arises (e.g. list item vs. detail view).</p>
<h3>The Model</h3>
<p>The most basic component is the Business Layer or the Model. This layer may talk to the database, call out to services, or do whatever else is needed to implement its interface. </p>
<p>There are many reasons why WPF cannot directly bind to this layer:</p>
<ul>
<li><strong>Not built for binding.</strong> No <code>INotifyPropertyChanged</code> or <code>INotifyCollectionChanged</code> interfaces.</li>
<li><strong>May block.</strong> Talking to the network or the hard disk may introduce delays which are unacceptable for the UI.</li>
<li><strong>Doesn&#8217;t know about multi-threading.</strong> Usually Models know only about Transactions, which are by themselves inherently single-threaded.</li>
<li><strong>No place for the View&#8217;s state.</strong> Where should the View store things like window sizes, selected items or other ephemeral information?</li>
</ul>
<p>None of these points is relevant when doing batch processing or when doing an ASP.NET site, which is a good benchmark for me that the Model shouldn&#8217;t burden itself with trying to solve them.</p>
<h3>The View Model</h3>
<p>To work around the &#8220;shortcomings&#8221; of the Model, this additional layer provides mechanisms to decouple user interaction from delays in the Model and a place to add additional properties to store and share View state between multiple Views.</p>
<p>The basis of all presentable Models is this abstract base class:</p>
<pre class="brush: c#; ">

public abstract class PresentableModel
  : INotifyPropertyChanged
{
  public ModelFactory Factory { get { return AppContext.Factory; } }
  protected IContext DataContext { get; private set; }
  protected IThreadManager UI { get { return AppContext.UiThread; } }
  protected IThreadManager Async { get { return AppContext.AsyncThread; } }

  public PresentableModel(IContext dataCtx) {
    UI.Verify();
    DataContext = dataCtx;
  }

  #region Public interface

  private ModelState _State = ModelState.Loading;
  public ModelState State {
    get {
      UI.Verify();
      return _State;
    }
    protected set {
      UI.Verify();
      if (value != _State) {
        _State = value;
        OnPropertyChanged(&quot;State&quot;);
      }
    }
  }

  #endregion

  #region INotifyPropertyChanged Members

  private event PropertyChangedEventHandler _PropertyChangedEvent;
  public event PropertyChangedEventHandler PropertyChanged {
    add {
      UI.Verify();
      _PropertyChangedEvent += value;
    }
    remove {
      UI.Verify();
      _PropertyChangedEvent -= value;
    }
  }

  protected virtual void OnPropertyChanged(string propertyName) {
    UI.Verify();
    if (_PropertyChangedEvent != null)
      _PropertyChangedEvent(this, new PropertyChangedEventArgs(propertyName));
  }

  protected void AsyncOnPropertyChanged(string propertyName) {
    Async.Verify();
    UI.Queue(UI, () =&gt; OnPropertyChanged(propertyName));
  }

  #endregion

}
</pre>
<ul>
<li><code>IThreadManager</code>: a component that can <code>Verify()</code> whether execution is on the right thread and <code>Queue()</code> an action to the managed thread. Each model has two of them. The <code>UI</code> manager takes care of the UI thread and the <code>Async</code> manager handles asynchronous actions. The default implementations use the <code>Dispatcher</code> and the <code>ThreadPool</code> respectively.
<li><code>State</code>: a flag to indicate in which state the PresentableModel is. Possible states include <code>Invalid</code>, <code>Loading</code>, and <code>Active</code>. This also shows the default pattern for a Property on a PresentableModel: It can only be accessed from the UI thread (lines 19 and 23) and only notifies on real changes (line 24 and 26).
<li><code>AsyncOnPropertyChanged()</code>: the only method on PresentableModel that may be called from a background thread (line 54). By convention the method name starts with &#8220;Async&#8221;. The easiest of tasks, calling <code>OnPropertyChanged()</code> on the UI thread, is handled by using <code>UI.Queue()</code>.
</ul>
<h4>Actual Presentables</h4>
<p>As an easy example of the flexibility of this model, I present you a <code>SearchActionModel</code> which can react on updates to the search term and to asynchronously batch queries to the database whose results are displayed incrementally.</p>
<pre class="brush: c#; ">

public class SearchActionModel: PresentableModel
{
  private string _searchTerm = null;
  public string SearchTerm {
    get {
      UI.Verify();
      return _searchTerm;
    }
    set {
      UI.Verify();
      if (_searchTerm != value) {
        _searchTerm = value;
        OnNotifyPropertyChanged(&quot;SearchTerm&quot;);
        Async.Queue(DataContext, AsyncUpdateResults);
      }
    }

  private ObservableCollection&lt;SearchResult&gt; _results = new ObservableCollection&lt;SearchResult&gt;();
  private ReadOnlyObservableCollection&lt;SearchResult&gt; _resultsProxy = new ReadOnlyObservableCollection&lt;SearchResult&gt;(_results);
  public ReadOnlyObservableCollection&lt;SearchResult&gt; Results {
    get {
      UI.Verify();
      return _resultsProxy;
    }
  }

  private void AsyncUpdateResults() {
    Async.Verify();
    UI.Queue(UI, () =&gt; {
      _results.Clear();
      State = ModelState.Loading;
      string searchTerm = _searchTerm;
      Async.Queue(DataContext, () =&gt; {
        var results = DataContext.GetQuery&lt;SearchResult&gt;().Where(r =&gt; r.Name.Contains(searchTerm));
        foreach(var r in results) {
          UI.Queue(UI, () =&gt; _results.Add(r));
        }
        UI.Queue(UI, () =&gt; State = ModelState.Active);
      });
    });
  }
}
</pre>
<p>Note how the multiple <code>Queue()</code> operations are nested to enforce an implicit and lock-less sequencing of the various actions.</p>
<p>The View is quite primitive:</p>
<pre class="brush: xml; ">

&lt;UserControl x:Class=&quot;App.View.SearchActionView&quot; ...&gt;
  &lt;DockPanel&gt;
    &lt;TextBox
      Text=&quot;{Binding SearchTerm}&quot;
      DockPanel.Dock=&quot;Top&quot; /&gt;
    &lt;ctrls:LoadingDindicator DockPanel.Dock=&quot;Top&quot; /&gt;
    &lt;ListBox
      ItemsSource=&quot;{Binding Results}&quot; /&gt;
  &lt;/StackPanel&gt;
&lt;/UserControl&gt;
</pre>
<blockquote><p>Note: the <code>LoadingIndicator</code> is a small widget binding to the <code>State</code> Property and displaying a little spinning wheel when the Model is not Active.
</p></blockquote>
<p>Of course even this trivial example is not without its share of problems:</p>
<ul>
<li>The <code>Results</code> collection is cleared on every input (line 30). A more sophisticated implementation might want to filter the results locally before going to the database again. Linq should make it easy to encapsulate the filter logic.</li>
<li>The loading code depends on a streaming Linq provider (line 35). If the underlying Linq provider blocks too long before returning the first result, a local workaround might be to implement client side paging and make multiple queries which only fetch a few elements each.</li>
<li>All <code>Queue()</code> magic aside, the code does play with fire and there are several possibilities to breach thread safety. For example, the search term has to be copied on the UI thread into a local variable (line 32) to avoid accessing the <code>SearchTerm</code> property from the background thread (line 34).</li>
</ul>
<h3>Conclusion and Future Work</h3>
<p>This organisation of threading and binding is a powerful way to get highly flexible and easily bindable model classes for use with WPF. Still programming in a free threading application is playing with fire and even slight missteps may produce subtle and hard to find bugs.</p>
<p>Other things are more of a nuisance because I didn&#8217;t come around implementing them yet. First, the <code>State</code> should support ref-counting semantics, because currently multiple parallel updates lead to the model being <code>Active</code> as soon as the first update finishes. The other things are related to the <code>IThreadManager</code>. It is currently impossible to abort actions once they&#8217;ve been queued and actions are mostly processed in FIFO which is annoying if somewhere is a longer running action, perhaps even consisting of multiple enqueued parts, which delay the reaction to the user&#8217;s last input.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2009/02/a-quick-sketch-of-asynchronous-view-models/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF ResourceDictionary Syntax</title>
		<link>http://dasz.at/index.php/2008/11/wpf-resourcedictionary-syntax/</link>
		<comments>http://dasz.at/index.php/2008/11/wpf-resourcedictionary-syntax/#comments</comments>
		<pubDate>Sat, 08 Nov 2008 10:52:51 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/11/wpf-resourcedictionary-syntax/</guid>
		<description><![CDATA[Moving the Style into the ResourceDictionary allows this example to work with current WPF releases.]]></description>
			<content:encoded><![CDATA[<p>The current top-hit on <a href="http://learnwpf.com/Posts/Post.aspx?postId=09ca2c76-4b45-4919-8747-eae036a7095e">WPF ResourceDictionary</a> on <a href="http://www.google.de/search?q=wpf+resourcedictionary">Google </a>has a minor error in the usage of WPF&#8217;s <a href="http://msdn.microsoft.com/en-us/library/system.windows.resourcedictionary.aspx">ResourceDictionary</a> class. Hopefully I can save someone the ten minutes of hate I had while searching for the cause of the strange error the Studio threw at me.</p>
<p><strong>Wrong:</strong></p>
<pre class="brush: xml; ">

&lt;Application.Resources&gt;
    &lt;ResourceDictionary&gt;
        &lt;ResourceDictionary.MergedDictionaries&gt;
            &lt;ResourceDictionary Source=&quot;TextStyle.xaml&quot; /&gt;
        &lt;/ResourceDictionary.MergedDictionaries&gt;
    &lt;/ResourceDictionary&gt;
    &lt;!-- other styles can appear in the resource dictionary too --&gt;
    &lt;Style TargetType=&quot;{x:Type Button}&quot;
           x:Key=&quot;ButtonStyle&quot;&gt;
        &lt;Setter Property=&quot;Background&quot;
                Value=&quot;#feca00&quot; /&gt;
    &lt;/Style&gt;
&lt;/Application.Resources&gt;
</pre>
<p><strong>Right:</strong></p>
<pre class="brush: xml; ">

&lt;Application.Resources&gt;
    &lt;ResourceDictionary&gt;
        &lt;ResourceDictionary.MergedDictionaries&gt;
            &lt;ResourceDictionary Source=&quot;TextStyle.xaml&quot; /&gt;
        &lt;/ResourceDictionary.MergedDictionaries&gt;
        &lt;!-- other styles can appear in the resource dictionary too --&gt;
        &lt;Style TargetType=&quot;{x:Type Button}&quot;
               x:Key=&quot;ButtonStyle&quot;&gt;
            &lt;Setter Property=&quot;Background&quot;
                    Value=&quot;#feca00&quot; /&gt;
        &lt;/Style&gt;
    &lt;/ResourceDictionary&gt;
&lt;/Application.Resources&gt;
</pre>
<p>Note the difference in where the additional <code>&lt;Style></code>s go.</p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/11/wpf-resourcedictionary-syntax/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Doing GUI architecture the Right Way</title>
		<link>http://dasz.at/index.php/2008/11/doing-gui-architecture-the-right-way/</link>
		<comments>http://dasz.at/index.php/2008/11/doing-gui-architecture-the-right-way/#comments</comments>
		<pubDate>Thu, 06 Nov 2008 20:03:20 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/11/doing-gui-architecture-the-right-way/</guid>
		<description><![CDATA[WPF binding is great, but directly binding the View to the Model has its limitations. As soon as the Model&#8217;s and the View&#8217;s structure diverge (which happens quite fast, I was surprised myself) the direct binding approach falls apart. The first example where I hit this was a tree of items which should be displayed [...]]]></description>
			<content:encoded><![CDATA[<p>WPF binding is great, but directly binding the View to the Model has its limitations. As soon as the Model&#8217;s and the View&#8217;s structure diverge (which happens quite fast, I was surprised myself) the direct binding approach falls apart. The first example where I hit this was a tree of items which should be displayed and selected in a (decorated) list. Data binding just doesn&#8217;t cut it. The solution lies in creating a so called <a href="http://blogs.msdn.com/dancre/archive/2006/10/11/datamodel-view-viewmodel-pattern-series.aspx">ViewModel</a>.</p>
<p><span id="more-64"></span></p>
<h2>The ViewModel</h2>
<p>The ViewModel acts as an <a href="http://en.wikipedia.org/wiki/Adapter_pattern">Adapter</a> between the View and the Model. A very intelligent Adapter. It contains all logic, properties and events to allow a &#8220;trivial&#8221; View implementation. This provides for a clear <a href="http://en.wikipedia.org/wiki/Separation_of_concerns">separation of concerns</a>:</p>
<ul>
<li>the <strong>Model</strong> as data store</li>
<li>the <strong>View</strong> as vehicle for actual user interaction, that is drawing pixels and receiving input events</li>
<li>the <strong>ViewModel</strong> to transform the data into view-specific structures, translate manipulation of these structures back into the Model and hold view-specific state</li>
</ul>
<h2>Example</h2>
<p>A simple example for a ViewModel (or <a href="http://msdn.microsoft.com/en-us/library/cc707885.aspx">Presenter Model</a>, as it called in the <a href="http://msdn.microsoft.com/en-us/library/cc707819.aspx">Composite Application Guidance for WPF</a>) is the <a href="http://msdn.microsoft.com/en-us/library/system.windows.data.collectionview.aspx"><code>CollectionView</code></a> used as Adapter between the ListBox and a collection. </p>
<blockquote><p>
You can think of a collection view as a layer on top of a binding source collection that allows you to navigate and display the collection based on sort, filter, and group queries, all without having to manipulate the underlying source collection itself. If the source collection implements the INotifyCollectionChanged interface, the changes that raise the CollectionChanged event are propagated to the views.
</p></blockquote>
<h2>Benefits</h2>
<p>One of the nice effects of a ViewModel is the ability to share such a model, giving instant synchronisation between multiple Views. This works because the individual Views do not have any state, but are completely dependent on the ViewModel.</p>
<p>Another subtle but nice point is the massive reduction in imposed structure on the View. Only a single, light-weight injection interface is needed to give the View access to the ViewModel. This allows more flexibility in evolving the ViewModel, since only breaking changes affect all Views. On the other hand, Views can incrementally support more and more features of a given ViewModel without having to pay big up-front costs in implementing/stubbing a huge interface. In the same vein, the ViewModel has no dependency of the View in any kind, which makes the ViewModel the ultimate <a href="http://www.cubido.at/Blog/tabid/176/EntryID/6/Default.aspx">lookless control</a>.</p>
<p>Automated testing became a big topic over the last years and the ViewModel follows the trend by being very easy to test. To test a presenter/controller in a MVP or MVC architecture, both the View and the Model have to be replaced for a test. Since a View of a ViewModel shouldn&#8217;t contain any &#8220;real&#8221; code, testing can concentrate on the functionality of the ViewModel and only mock up the Model, something which is needed for most tests of components using the Model anyways.</p>
<p>Last (but perhaps not least) is a purely aesthetic point: All dependencies in a ViewModel architecture point in the same direction. The Model works with a data source, the Business Logic works with the Model, the ViewModel works with the Business Logic and the Model, and the View only works with the ViewModel. This enables the uniform re-use of the same mechanisms and patterns &#8212; Validation, Transactions, Change Notification, etc &#8212; over the various levels of the application.</p>
<h2>Conclusion</h2>
<p>ViewModels represent the current top of the evolution in <a href="http://www.cubido.at/Blog/tabid/176/EntryID/6/Default.aspx">lookless controls</a>. By combining data binding and the programmatic power of a Presenter/Controller component into a single concept without dependencies on a specific View technology, they provide a high degree of flexibility in representing the internal state of an application without getting bogged down in the intricate details of designing a great user experience. </p>
<p>I&#8217;m already thrilled how this will work out in more complex scenarios. And what&#8217;ll come next <img src='http://dasz.at/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/11/doing-gui-architecture-the-right-way/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to style a WPF TabControl</title>
		<link>http://dasz.at/index.php/2008/07/how-to-style-a-wpf-tabcontrol/</link>
		<comments>http://dasz.at/index.php/2008/07/how-to-style-a-wpf-tabcontrol/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 12:42:48 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/07/how-to-style-a-wpf-tabcontrol/</guid>
		<description><![CDATA[A very good example of how to style a WPF TabControl.
From Brandon Cannaday at Switch on the code.
I use this Style to surround each TabItem Content with a ScrollViewer:


        &#60;Style TargetType=&#34;{x:Type TabControl}&#34;&#62;
            &#60;Setter Property=&#34;Template&#34;&#62;
    [...]]]></description>
			<content:encoded><![CDATA[<p>A very good example of how to style a WPF TabControl.</p>
<p>From <a href="http://blog.paranoidferret.com/index.php/2008/01/18/the-wpf-tab-control-inside-and-out/">Brandon Cannaday at Switch on the code</a>.</p>
<p>I use this Style to surround each TabItem Content with a ScrollViewer:</p>
<pre class="brush: xml; ">

        &lt;Style TargetType=&quot;{x:Type TabControl}&quot;&gt;
            &lt;Setter Property=&quot;Template&quot;&gt;
                &lt;Setter.Value&gt;
                    &lt;ControlTemplate TargetType=&quot;{x:Type TabControl}&quot;&gt;
                        &lt;Grid&gt;
                            &lt;Grid.RowDefinitions&gt;
                                &lt;RowDefinition Height=&quot;Auto&quot;/&gt;
                                &lt;RowDefinition Height=&quot;*&quot;/&gt;
                            &lt;/Grid.RowDefinitions&gt;
                            &lt;TabPanel Grid.Row=&quot;0&quot; IsItemsHost=&quot;True&quot; /&gt;
                            &lt;ScrollViewer Grid.Row=&quot;1&quot;
                                VerticalScrollBarVisibility=&quot;Auto&quot;
                                Margin=&quot;5,5,5,5&quot;
                                Background=&quot;White&quot;&gt;
                                &lt;ContentPresenter ContentSource=&quot;SelectedContent&quot; /&gt;
                            &lt;/ScrollViewer&gt;
                        &lt;/Grid&gt;
                    &lt;/ControlTemplate&gt;
                &lt;/Setter.Value&gt;
            &lt;/Setter&gt;
        &lt;/Style&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/07/how-to-style-a-wpf-tabcontrol/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Reference Project: New User Interface for Simulation Tool</title>
		<link>http://dasz.at/index.php/2008/06/referenzprojekt-neue-benutzeroberflache-fur-simulationswerkzeug/</link>
		<comments>http://dasz.at/index.php/2008/06/referenzprojekt-neue-benutzeroberflache-fur-simulationswerkzeug/#comments</comments>
		<pubDate>Wed, 04 Jun 2008 18:24:16 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Business]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/06/referenzprojekt-neue-benutzeroberflache-fur-simulationswerkzeug/</guid>
		<description><![CDATA[
Soil.NET is a port of an old DOS application written in Pascal to the .NET framework. It is a one-off programming project for the civil engineering office Steinhauser, who are useing the application to support writing expertises in the area of vibration protection and seismology. While the mathematical core could be taken almost literally, the [...]]]></description>
			<content:encoded><![CDATA[<p><center><img id="image50" src="http://dasz.at/wp-content/uploads/2008/06/soilnet-screenshot-ausschnitt.png" alt="Soil.NET detail" /></center></p>
<p>Soil.NET is a port of an old <a href="http://en.wikipedia.org/wiki/DOS">DOS</a> application written in <a href="http://en.wikipedia.org/wiki/Pascal_%28programming_language%29" title="old programming language">Pascal</a> to the <a href="http://en.wikipedia.org/wiki/.NET_Framework">.NET framework</a>. It is a one-off programming project for the <a href="http://steinhauser.eu/">civil engineering office Steinhauser</a>, who are useing the application to support writing expertises in the area of vibration protection and seismology. While the mathematical core could be taken almost literally, the use of a modern GUI toolkit <a href="http://de.wikipedia.org/wiki/Windows_Presentation_Foundation" title="Windows Presentation Foundation">WPF</a> enabled important improvements in user interface experience:</p>
<p><span id="more-44"></span></p>
<ul>
<li><strong>Free data entry:</strong> the DOS application only allowed sequential input. The WPF implementation not only enables free entry and correcting of parameters, but also displays the results immediately to the user. The feedback allows users to test more combinations of parameters in the same time.</li>
<li><strong>Model comparisons:</strong> as with data entry, models could only be input sequentially. Single typos thus lead to having re-type the whole dataset. The new implementation allows models to be input independently and to choose, display, and print different charts and combinations without having to re-enter any data.</li>
<li><strong>Graphical quality:</strong> the DOS application was restricted to 640&#215;480 <a href="http://en.wikipedia.org/wiki/Pixel">pixels</a> on screen and when printing. Of course this doesn&#8217;t meet current expectations and is noted negatively when including the graphics in expertises and similar documents. Trhough using the <a href="http://zedgraph.org/">ZedGraph</a> library, graphics can be created in arbitrary resolutions and print outs conform to the specifications of the printer and the used paper formats.</li>
</ul>
<p>Finally a <a id="p48" href="http://dasz.at/wp-content/uploads/2008/06/testausdruck.pdf" title="printed page">printed page</a> and a screenshot of the complete application:</p>
<p><center><br />
<a class="imagelink" href="http://dasz.at/wp-content/uploads/2008/06/soilnet-screenshot-gros.png" title="Soil.NET complete"><img id="image47" src="http://dasz.at/wp-content/uploads/2008/06/soilnet-screenshot-gros.thumbnail.png" alt="Soil.NET complete" /></a><br />
</center></p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/06/referenzprojekt-neue-benutzeroberflache-fur-simulationswerkzeug/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF &amp; Namespacemapping</title>
		<link>http://dasz.at/index.php/2008/02/wpf-namespacemapping/</link>
		<comments>http://dasz.at/index.php/2008/02/wpf-namespacemapping/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 17:18:06 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/02/wpf-namespacemapping/</guid>
		<description><![CDATA[This happened to me when I tried to import a Namespace of an Assembly into my XAML Page:
This sucks: &#8220;clr-namespace:My.Sub; assembly=MyAssembly&#8221;
This works: &#8220;clr-namespace:My.Sub;assembly=MyAssembly&#8221;
See the difference? Unbelievable, but there is just a space between the &#8216;;&#8217; and &#8220;assembly&#8221;. Sure, it&#8217;s not possible to use Trim() during parsing. Or there is another reason I dont know why.
 
]]></description>
			<content:encoded><![CDATA[<p>This happened to me when I tried to import a Namespace of an Assembly into my XAML Page:</p>
<p>This sucks: &#8220;<code>clr-namespace:My.Sub; assembly=MyAssembly</code>&#8221;</p>
<p>This works: &#8220;<code>clr-namespace:My.Sub;assembly=MyAssembly</code>&#8221;</p>
<p>See the difference? Unbelievable, but there is just a space between the &#8216;;&#8217; and &#8220;assembly&#8221;. Sure, it&#8217;s not possible to use Trim() during parsing. Or there is another reason I dont know why.</p>
<p> </p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/02/wpf-namespacemapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Wow Wow Wow!!! &#8211; Wii Remote and WPF</title>
		<link>http://dasz.at/index.php/2008/02/wow-wow-wow/</link>
		<comments>http://dasz.at/index.php/2008/02/wow-wow-wow/#comments</comments>
		<pubDate>Tue, 12 Feb 2008 19:16:08 +0000</pubDate>
		<dc:creator>Arthur Zaczek</dc:creator>
				<category><![CDATA[Privat]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/02/wow-wow-wow/</guid>
		<description><![CDATA[Wii Remote for a

Whiteboard
Finger Tracking
Head Tracking

http://johnnylee.net/projects/wii/
COOOOLLLLL!!!!
And for all WPF Friends:
http://www.cynergysystems.com/blogs/page/rickbarraza?entry=connecting_to_the_wii_control
]]></description>
			<content:encoded><![CDATA[<p>Wii Remote for a</p>
<ul>
<li>Whiteboard</li>
<li>Finger Tracking</li>
<li>Head Tracking</li>
</ul>
<p><a href="http://www.cs.cmu.edu/~johnny/projects/wii/">http://johnnylee.net/projects/wii/</a></p>
<p>COOOOLLLLL!!!!</p>
<p>And for all WPF Friends:</p>
<p><a href="http://www.cynergysystems.com/blogs/page/rickbarraza?entry=connecting_to_the_wii_control">http://www.cynergysystems.com/blogs/page/rickbarraza?entry=connecting_to_the_wii_control</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/02/wow-wow-wow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Pushbutton from a Icon</title>
		<link>http://dasz.at/index.php/2008/02/wpf-push-button-with-picture/</link>
		<comments>http://dasz.at/index.php/2008/02/wpf-push-button-with-picture/#comments</comments>
		<pubDate>Thu, 07 Feb 2008 14:15:20 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/02/wpf-push-button-with-picture/</guid>
		<description><![CDATA[Today I posted the first article about my recent WPF experiences to CodeProject: &#8220;WPF: IconButton &#8211; Creating a little push button from a icon.&#8221;
Abstract: While there are a few demo videos how to create nice buttons with Expression Blend, I didn&#8217;t find a straight-forward description how to do a nice button from a image. This [...]]]></description>
			<content:encoded><![CDATA[<p>Today I posted the first article about my recent WPF experiences to <a href="http://www.codeproject.com/">CodeProject</a>: &#8220;<a href="http://www.codeproject.com/KB/WPF/WPF-IconButton.aspx">WPF: IconButton</a> &#8211; Creating a little push button from a icon.&#8221;</p>
<blockquote><p><strong>Abstract:</strong> While there are a few demo videos how to create nice buttons with Expression Blend, I didn&#8217;t find a straight-forward description how to do a nice button from a image. This article tries to fill this gap and a bit more. The IconButtonStyle takes the contents of the button, decorates them with a little shadow and when the user presses the butten, it generates a subtle animation &#8220;pushing&#8221; the content into the screen.</p></blockquote>
<p><img src="http://dasz.at/wp-content/uploads/2008/02/wpf-iconbutton.png" alt="Demo Application" /></p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/02/wpf-push-button-with-picture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>WPF: Embedding Images in the Assembly</title>
		<link>http://dasz.at/index.php/2008/01/wpf-embedding-images-in-the-assembly/</link>
		<comments>http://dasz.at/index.php/2008/01/wpf-embedding-images-in-the-assembly/#comments</comments>
		<pubDate>Fri, 25 Jan 2008 08:43:54 +0000</pubDate>
		<dc:creator>David Schmitt</dc:creator>
				<category><![CDATA[Tech]]></category>
		<category><![CDATA[WPF]]></category>

		<guid isPermaLink="false">http://dasz.at/index.php/2008/01/wpf-embedding-images-in-the-assembly/</guid>
		<description><![CDATA[Yesterday, I searched for a possiblity to include PNGs into my assemblies and access tem from WPF/XAML. The only stuff I found was Chad Campbell&#8217;s &#8220;Point an Image to an Embedded Resource&#8220;. Chad recommends using embedded resources and manually extracting them with Assembly.GetManifestResourceStream and PngBitmapDecoder in the code-behind. Yuck! That would mean giving every Image [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday, I searched for a possiblity to include PNGs into my assemblies and access tem from WPF/XAML. The only stuff I found was <a href="http://cornucopia30.blogspot.com/">Chad Campbell</a>&#8217;s &#8220;<a href="http://cornucopia30.blogspot.com/2007/08/wpf-point-image-to-embedded-resource.html">Point an Image to an Embedded Resource</a>&#8220;. Chad recommends using embedded resources and manually extracting them with <code>Assembly.GetManifestResourceStream</code> and <code>PngBitmapDecoder</code> in the code-behind. Yuck! That would mean giving every <code>Image</code> a <code>Name</code> and jump through hoops to share memory and what not.</p>
<p>Today I looked at it again and&#8230;<span id="more-15"></span><br />
 thought I should be able to create a custom <code>System.Windows.Media.ImageSource</code> using a hidden <code>BitmapSource</code> for XAML usage. Far from it! While <code>ImageSource</code> is <code>public abstract</code>, it uses some &#8220;private parts&#8221; from <code>Windows.Media.Composition.DUCE</code> which are not available to the common folk.</p>
<p>Finally uncle google came to the rescue: in a microsoft forum posting (&#8220;<a href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=912762&#038;SiteID=1">Using Bitmap resources from .resx file in WPF</a>&#8220;) <a href="http://nerddawg.blogspot.com">Ashish Shetty</a> explains how to use a special URI syntax to access resources directly from XAML. The catch is that the images have to be built as &#8220;<code>Resource</code>&#8221; and not as &#8220;<code>Embedded Resource</code>&#8220;. This seems to be only available if the assembly was created from one of the WPF project templates[1]. But if everything is done right, the resource can be accessed by simply setting the &#8220;<code>Source</code>&#8221; property:</p>
<pre class="brush: xml; ">

&lt;!-- local assembly --&gt;
&lt;Image Source=&quot;/directory/foo.png&quot; /&gt;
&lt;!-- referenced assembly --&gt;
&lt;Image Source=&quot;/AssemblyName;component/directory/foo.png&quot; /&gt;
</pre>
<p>More details can be found in the MSDN article &#8220;<a href="http://msdn2.microsoft.com/en-us/library/aa970494.aspx">Windows Presentation Foundation Application Resource, Content, and Data Files</a>&#8220;.</p>
<p>[1] See the last comment at <a href="http://www.codeprof.com/dev-archive/209/153-119-2094281.shtm">How to use resources (images) in dll assembly?</a></p>
]]></content:encoded>
			<wfw:commentRss>http://dasz.at/index.php/2008/01/wpf-embedding-images-in-the-assembly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
