<!-- Window1.xaml -->
<Window
  x:Class="AdoBinding.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:AdoBinding"
  xmlns:tableAdapters="clr-namespace:AdoBinding.FamilyTableAdapters"
  Title="AdoBinding"
  Height="325"
  Width="400">
  <Window.Resources>
    <ObjectDataProvider
      x:Key="Family"
      ObjectType="{x:Type tableAdapters:PeopleTableAdapter}"
      IsAsynchronous="True"
      MethodName="GetData" />

    <local:AgeToForegroundConverter x:Key="ageConverter" />
  </Window.Resources>
  <Grid DataContext="{StaticResource Family}">
    <Grid.RowDefinitions>
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
      <RowDefinition Height="Auto" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="Auto" />
      <ColumnDefinition Width="*" />
    </Grid.ColumnDefinitions>
    <ListBox Grid.Row="0" Grid.Column="1" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" Margin="5">
      <ListBox.GroupStyle>
        <x:Static Member="GroupStyle.Default" />
      </ListBox.GroupStyle>
      <ListBox.ItemTemplate>
        <DataTemplate>
          <TextBlock>
            <TextBlock Text="{Binding Path=Name}" />
            (age: <TextBlock Text="{Binding Path=Age}" Foreground="{Binding Path=Age, Converter={StaticResource ageConverter}}" />)
          </TextBlock>
        </DataTemplate>
      </ListBox.ItemTemplate>
    </ListBox>
    <TextBlock Grid.Row="1" Grid.Column="0" Margin="5" VerticalAlignment="Center">Name:</TextBlock>
    <TextBox Grid.Row="1" Grid.Column="1" Margin="5" Text="{Binding Path=Name}" />
    <TextBlock Grid.Row="2" Grid.Column="0" Margin="5" VerticalAlignment="Center">Age:</TextBlock>
    <TextBox Grid.Row="2" Grid.Column="1" Margin="5" Text="{Binding Path=Age}"
             Foreground="{Binding Path=Age, Converter={StaticResource ageConverter}}" />
    <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Horizontal">
      <Button x:Name="birthdayButton" Width="75" Margin="5">Birthday</Button>
      <Button x:Name="backButton" Width="75" Margin="5">&lt;</Button>
      <Button x:Name="forwardButton" Width="75" Margin="5">&gt;</Button>
    </StackPanel>
    <StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal">
      <Button x:Name="addButton" Width="75" Margin="5">Add</Button>
      <Button x:Name="sortButton" Width="75" Margin="5">Sort</Button>
      <Button x:Name="filterButton" Width="75" Margin="5">Filter</Button>
      <Button x:Name="groupButton" Width="75" Margin="5">Group</Button>
    </StackPanel>
  </Grid>
</Window>
