<Window
  x:Class="ObjectBinding.Window1"
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:local="clr-namespace:ObjectBinding"
  xmlns:sys="clr-namespace:System;assembly=mscorlib"
  Title="ListBinding"
  Height="325"
  Width="400">
  <Window.Resources>
    <ObjectDataProvider
      x:Key="Family"
      ObjectType="{x:Type local:RemotePeopleLoader}"
      IsAsynchronous="True"
      MethodName="LoadPeople">
      <ObjectDataProvider.MethodParameters>
        <sys:String>http://sellsbrothers.com/boys.dat</sys:String>
        <sys:String>http://sellssisters.com/girls.dat</sys:String>
      </ObjectDataProvider.MethodParameters>
    </ObjectDataProvider>

    <local:AgeToForegroundConverter x:Key="ageConverter" />
    <DataTemplate DataType="{x:Type local:Person}">
      <TextBlock>
        <TextBlock Text="{Binding Path=Name}" />
        (age: <TextBlock Text="{Binding Path=Age}" Foreground="{Binding Path=Age, Converter={StaticResource ageConverter}}" />)
      </TextBlock>
    </DataTemplate>
  </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>

    <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 Name="birthdayButton" Width="75" Margin="5">Birthday</Button>
      <Button Name="backButton" Width="75" Margin="5">&lt;</Button>
      <Button Name="forwardButton" Width="75" Margin="5">&gt;</Button>
    </StackPanel>
    <StackPanel Grid.Row="4" Grid.Column="1" Orientation="Horizontal">
      <Button Name="addButton" Width="75" Margin="5">Add</Button>
      <Button Name="sortButton" Width="75" Margin="5">Sort</Button>
      <Button Name="filterButton" Width="75" Margin="5">Filter</Button>
      <Button Name="groupButton" Width="75" Margin="5">Group</Button>
    </StackPanel>
  </Grid>
</Window>
