<!-- Window1.xaml -->
<Window x:Class="DataBindingDemo.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DataBindingDemo"
    Width="250" 
    Height="150" 
    Title="Nick Names">
  <Window.Resources>
    <Style x:Key="myStyle" TargetType="{x:Type TextBlock}">
      <Setter Property="VerticalAlignment" Value="Center" />
      <Setter Property="Margin" Value="2" />
      <Setter Property="FontWeight" Value="Bold" />
      <Setter Property="FontStyle" Value="Italic" />
    </Style>
    <local:Nicknames x:Key="names">
      <local:Nickname Name="Don" Nick="Naked" />
      <local:Nickname Name="Martin" Nick="Gudge" />
      <local:Nickname Name="Tim" Nick="Stinky" />
    </local:Nicknames>
  </Window.Resources>
  <!--<DockPanel x:Name="dockPanel">-->
  <DockPanel DataContext="{StaticResource names}">
    <StackPanel DockPanel.Dock="Top" Orientation="Horizontal">
      <!--<TextBlock VerticalAlignment="Center">Name: </TextBlock>-->
      <TextBlock Style="{StaticResource myStyle}">Name: </TextBlock>
      <TextBox Text="{Binding Path=Name}" />
      <!--<TextBlock VerticalAlignment="Center">Nick: </TextBlock>-->
      <TextBlock Style="{StaticResource myStyle}">Nick: </TextBlock>
      <TextBox Text="{Binding Path=Nick}" />
    </StackPanel>
    <Button DockPanel.Dock="Bottom" x:Name="addButton" Content="Add">
      <Button.Template>
        <ControlTemplate TargetType="{x:Type Button}">
          <Grid>
            <Ellipse Width="128" Height="32" Fill="Yellow" Stroke="Black" />
            <ContentPresenter VerticalAlignment="Center" HorizontalAlignment="Center" />
          </Grid>
        </ControlTemplate>
      </Button.Template>
    </Button>
    <ListBox ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True">
      <ListBox.ItemTemplate>
        <DataTemplate>
          <TextBlock>
            <TextBlock Text="{Binding Path=Name}" />:
            <TextBlock Text="{Binding Path=Nick}" />
          </TextBlock>
        </DataTemplate>
      </ListBox.ItemTemplate>
    </ListBox>
  </DockPanel>
</Window>
