<Window x:Class="SDKSample.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:SDKSample"
  SizeToContent="WidthAndHeight" 
  Title="Introduction to Data Templating Sample">
  <Window.Resources>
    <local:Tasks x:Key="myTodoList"/>
    
    <local:TaskListDataTemplateSelector x:Key="myDataTemplateSelector"/>
    
    <DataTemplate x:Key="importantTaskTemplate">
      <DataTemplate.Resources>
        <Style TargetType="TextBlock">
          <Setter Property="FontSize" Value="20"/>
        </Style>
      </DataTemplate.Resources>
      <Border Name="border" BorderBrush="Red" BorderThickness="1"
              Padding="5" Margin="5">
        <DockPanel HorizontalAlignment="Center">
          <TextBlock Text="{Binding Path=Description}" />
          <TextBlock>!</TextBlock>
        </DockPanel>
      </Border>
    </DataTemplate>

    <!--<SnippetAddingMore>-->

    <!--<SnippetDT>-->
    <DataTemplate x:Key="myTaskTemplate">
  <!--</SnippetDT>-->
      <Border Name="border" BorderBrush="Aqua" BorderThickness="1"
              Padding="5" Margin="5">
        <Grid>
          <Grid.RowDefinitions>
            <RowDefinition/>
            <RowDefinition/>
            <RowDefinition/>
          </Grid.RowDefinitions>
          <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition />
          </Grid.ColumnDefinitions>
          <TextBlock Grid.Row="0" Grid.Column="0" Text="Task Name:"/>
          <TextBlock Grid.Row="0" Grid.Column="1" Text="{Binding Path=TaskName}" />
          <TextBlock Grid.Row="1" Grid.Column="0" Text="Description:"/>
          <TextBlock Grid.Row="1" Grid.Column="1" Text="{Binding Path=Description}"/>
          <TextBlock Grid.Row="2" Grid.Column="0" Text="Priority:"/>
          <TextBlock Grid.Row="2" Grid.Column="1" Text="{Binding Path=Priority}"/>
        </Grid>
      </Border>
      <!--</SnippetAddingMore>-->

      <!--<SnippetDataTrigger>-->
    <DataTemplate.Triggers>
      <DataTrigger Binding="{Binding Path=TaskType}">
        <DataTrigger.Value>
          <local:TaskType>Home</local:TaskType>
        </DataTrigger.Value>
        <Setter TargetName="border" Property="BorderBrush" Value="Yellow"/>
      </DataTrigger>
    </DataTemplate.Triggers>
    <!--</SnippetDataTrigger>-->
      
      <!--<SnippetAddingMore2>-->
    </DataTemplate>
    <!--</SnippetAddingMore2>-->
  </Window.Resources>

  <StackPanel>
    <TextBlock FontSize="20" Text="My Task List:"/>
    <ListBox Width="400" Margin="10"
             ItemsSource="{Binding Source={StaticResource myTodoList}}"
             ItemTemplateSelector="{StaticResource myDataTemplateSelector}"
             HorizontalContentAlignment="Stretch" 
             IsSynchronizedWithCurrentItem="True"/>
    <TextBlock FontSize="20" Text="Information:"/>
    <ContentControl Content="{Binding Source={StaticResource myTodoList}}"
                    ContentTemplate="{StaticResource myTaskTemplate}"/>
  </StackPanel>
</Window>