<Window x:Class="FeenPhone.WPFApp.AddressBookWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
        mc:Ignorable="d"
        Title="Feen Book" Height="300" Width="400" Name="thisWindow">
    <Window.Resources>
        <CollectionViewSource x:Key="designView"
            d:DesignSource="{d:DesignData Source=WPFControls/SampleData/AddressBookWindow.xaml}" 
            Source="{Binding RuntimeBookingRowCollection}">
        </CollectionViewSource>
    </Window.Resources>
    <DockPanel>
        <Grid DockPanel.Dock="Bottom" Margin="2 2 2 2" ToolTip="Add a new entry">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="50"/>
                <ColumnDefinition/>
                <ColumnDefinition Width="48"/>
            </Grid.ColumnDefinitions>
            <Label Grid.Column="0">Name:</Label>
            <TextBox Name="txtName" Grid.Column="1" KeyDown="textBox_KeyDown" />
            <Label Grid.Column="2">Addr:</Label>
            <TextBox Name="txtServer" Grid.Column="3" 
                     Background="{Binding ElementName=thisWindow, Path=ServerIsValid, Converter={StaticResource ValidationColorConverter}}" 
                     GotFocus="txtServer_GotFocus"
                     TextChanged="txtServer_TextChanged"
                     KeyDown="textBox_KeyDown"
                     LostFocus="txtServer_LostFocus"/>
            <Button Name="btnAdd" Grid.Column="4" Click="Add_Button_Click">Add</Button>
        </Grid>
        <Border DockPanel.Dock="Bottom" Background="{DynamicResource clrSectionDivider}" Height="2" BorderThickness="0 0 0 0"></Border>
        <ListView
            Name="listView" 
            SizeChanged="ListView_SizeChanged" 
            ScrollViewer.VerticalScrollBarVisibility="Visible" 
            ItemsSource="{Binding Source={StaticResource designView}}">
            <ListView.Resources>
                <ContextMenu x:Key="itemsMenu">
                    <MenuItem Header="Delete" Click="MenuItem_Delete_Click" >
                        <MenuItem.Icon>
                            <Image Source="Resources/Images/trash-26.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                    <MenuItem Header="Edit Name" Click="MenuItem_Edit_Click">
                        <MenuItem.Icon>
                            <Image Source="Resources/Images/edit-26.png" />
                        </MenuItem.Icon>
                    </MenuItem>
                </ContextMenu>
            </ListView.Resources>

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <EventSetter Event="MouseDoubleClick" Handler="Item_MouseDoubleClick"/>
                    <Setter Property="ContextMenu" Value="{StaticResource itemsMenu}"/>
                    <Setter Property="Tag" Value="{Binding}"/>
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView>
                    <GridViewColumn Header="Name">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Label Content="{Binding Path=Name}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                    <GridViewColumn Header="Address">
                        <GridViewColumn.CellTemplate>
                            <DataTemplate>
                                <Label Content="{Binding Path=Address}" />
                            </DataTemplate>
                        </GridViewColumn.CellTemplate>
                    </GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
    </DockPanel>
</Window>
