<mah:MetroWindow x:Class="ZKuP.ManageUsers"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
        xmlns:local="clr-namespace:ZKuP"
        mc:Ignorable="d"
        Title="Manage Users" Height="657" Width="450" Loaded="Window_Loaded" LocationChanged="Window_LocationChanged">
    <mah:MetroWindow.Resources>
        <local:IntToRole x:Key="IntToRole"/>
    </mah:MetroWindow.Resources>
    <Grid>
        <Button x:Name="btnAddUser" FontSize="12" Padding="-2" Content="Add" Margin="10,130,0,0" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Width="140" Click="BtnAddUser_Click"/>
        <Button x:Name="btnDelUser" FontSize="12" Padding="-2" Content="Markierten User löschen" Margin="10,160,0,0" Height="20" VerticalAlignment="Top" HorizontalAlignment="Left" Width="140" Click="btnDelUser_Click"/>
        <Button x:Name="btnClose" Content="Close" FontSize="12" Padding="-2" Margin="0,0,10,10" Height="20" VerticalAlignment="Bottom" HorizontalAlignment="Right" Width="75" Click="BtnClose_Click"/>
        <TextBox x:Name="tbUsername" HorizontalAlignment="Left" Height="23" Margin="10,30,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="140" Text=""/>
        <ComboBox x:Name="cbRole" SelectedItem="{Binding Role, Mode=OneWay, Converter={StaticResource IntToRole}}" ItemsSource="{Binding RoleList}" HorizontalAlignment="Left" Margin="10,78,0,0" VerticalAlignment="Top" Width="140"/>
        
        <DataGrid x:Name="dgUsers" Margin="160,10,10,46" ItemsSource="{Binding Path=., Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" CanUserAddRows="False" AutoGenerateColumns="False" PreviewKeyDown="DgUsers_PreviewKeyDown" CellEditEnding="dgUsers_CellEditEnding">
            <DataGrid.Columns>
                <DataGridTextColumn Binding="{Binding Username, Mode=TwoWay}" ClipboardContentBinding="{x:Null}" Header="Username" Width="*" SortDirection="Ascending"/>
                <DataGridTemplateColumn ClipboardContentBinding="{x:Null}" Header="Role" Width="100">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox x:Name="cbDGRole" SelectedItem="{Binding Role, Mode=OneWay, Converter={StaticResource IntToRole}}" ItemsSource="{Binding RoleList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:ManageUsers}}}" DropDownClosed="cbDGRole_DropDownClosed"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <TextBlock HorizontalAlignment="Left" Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Margin="10,9,0,0" TextWrapping="Wrap" Text="Username" VerticalAlignment="Top"/>
        <TextBlock HorizontalAlignment="Left" Foreground="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" Margin="10,57,0,0" TextWrapping="Wrap" Text="Role" VerticalAlignment="Top"/>
    </Grid>
</mah:MetroWindow>
