title: How can I create a DataTemplate with Expression Blend 3?
body: <p>I'm currently experimenting with <a href="http://www.microsoft.com/expression/try-it/blendpreview.aspx" rel="nofollow noreferrer">Expression Blend 3 MIX09 version</a> with the idea to <strong>use it primarily for an MVVM structured site with databinding, being able to view live data as I design</strong>. So far I've been <strong>very impressed</strong> and have to say that <strong>Blend 3's generated XAML is not as bad as people say it is</strong>. I got the following two examples working, one with data binding and one with user controls (views) being loaded dynamically. I can stay in Expression Blend 90% of the time while I design my application, seeing live data coming from my ViewModels as I design. I switch to Visual Studio only for e.g. creating config files, or adding references is easier. The <strong>improved intellisense of Blend 3</strong> enabled me to stay in Blend for much of my coding as well:</p>
  
  <ul>
  <li><a href="http://tanguay.info/web/index.php?pg=codeExamples&amp;id=168" rel="nofollow noreferrer">MVVM base application that can be edited with Expression Blend and Visual Studio</a></li>
  <li><a href="http://tanguay.info/web/index.php?pg=codeExamples&amp;id=167" rel="nofollow noreferrer">How to structure a WPF application with DataBinding so you can enhance it in Expression Blend</a></li>
  </ul>
  
  <p>One thing I'm surprised that I can't do in Expression Blend, though, is after I have created a ListBox, I would expect that I could do a right-click and <strong>create a DataTemplate</strong>. I can of course create a DataTemplate in code, then under Resources/Window I find it again, can click on a button next to it to "go into the DataTemplate" and see the controls inside in my Objects and Timeline panel, which is nice. But creating a DataTemplate from a control is so common, I would think there is a way to do it that I am just missing.</p>
  
  <p><strong>Where in Blend 3 can you "create a DataTemplate" for a ListBox or ListView, etc?</strong></p>
  
  <pre><code>&lt;UserControl
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      xmlns:local="clr-namespace:TestDynamic456"
      mc:Ignorable="d"
      x:Class="TestDynamic456.CustomersView"
      x:Name="UserControl"
      d:DesignWidth="640" d:DesignHeight="480"&gt;
  
      &lt;UserControl.Resources&gt;
          &lt;local:CustomersViewModel x:Key="CustomersDataProvider"/&gt;
      &lt;/UserControl.Resources&gt;
      &lt;StackPanel x:Name="LayoutRoot" Background="{x:Null}"&gt;
  
          &lt;ListBox ItemsSource="{Binding Path=GetAll, Source={StaticResource CustomersDataProvider}}"/&gt;
  
      &lt;/StackPanel&gt;
  &lt;/UserControl&gt;
  </code></pre>