title: Windows StoreApp XAML: Changing ItemTemplate in GridView based on Data type
body: <p>I am working on developing Windows Store App using C#/XAML. I have experience primarily in iOS and to some extent Android app development, but not yet comfortable with C#/XAML world.</p>
  
  <p>Here is my issue in GridView based page (Based on the nice template VS2012 generates).</p>
  
  <p>I have a gridview and its collection is bound to a data retrieved from network and it works fine.
  But I want to change the grid item depending on the data.
  For example: I have files and folders that I would like to show using different grid view items. </p>
  
  <p>My Question: How would I use a different DataTemplate for the ItemTemplate depending on the data? For example, for "Folders", I will have only one textblock which is vertically centered and for File, I will have the 2 textblocks and visually different.</p>
  
  <p>Am I going the right path or should I be doing completely different?</p>
  
  <p>The XAML Portion is</p>
  
  <pre><code>&lt;GridView
              x:Name="itemGridView"
              AutomationProperties.AutomationId="ItemGridView"
              AutomationProperties.Name="Grouped Items"
              Grid.RowSpan="3"
              Padding="116,137,40,46"
              ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
              ItemTemplate="{StaticResource FileEntriesTemplate}"
              ItemClick="ItemView_ItemClick"
              IsItemClickEnabled="True"
              SelectionMode="None"
              IsSwipeEnabled="false"&gt;
  </code></pre>
  
  <p>The Template is</p>
  
  <pre><code>&lt;DataTemplate x:Key="FileEntriesTemplate"&gt;
  &lt;Grid HorizontalAlignment="Left" Width="400" Height="80" Background="Beige"&gt;
      &lt;Grid.ColumnDefinitions&gt;
          &lt;ColumnDefinition Width="80"/&gt;
          &lt;ColumnDefinition Width="*"/&gt;
      &lt;/Grid.ColumnDefinitions&gt;
      &lt;Image Source="{Binding Image}" Stretch="Uniform" Grid.Column="0" Margin="10,0,0,0" AutomationProperties.Name="{Binding Title}"/&gt;
  
      &lt;StackPanel Orientation="Vertical" Grid.Column="1" Background="Transparent"&gt;
          &lt;TextBlock Text="{Binding Title}" Foreground="Black" Style="{StaticResource LargeTitleTextStyle}" Margin="20,20,10,0"/&gt;
          &lt;TextBlock Text="{Binding Subtitle}" Foreground="gray" Style="{StaticResource CaptionTextStyle}" TextWrapping="NoWrap" Margin="20,10,0,30"/&gt;
      &lt;/StackPanel&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p></p>