<Window x:Class="ZKuP.MainWindow"
        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:local="clr-namespace:ZKuP"
        mc:Ignorable="d"
        Title="Zutrittskontrolle" Height="450" Width="800">


    <Window.Resources>
        <local:ConvertToBackground x:Key="ConvertToBack"></local:ConvertToBackground>
    </Window.Resources>
    
    <Grid>
        <DataGrid x:Name="dgOverview" ItemsSource="{Binding Path=., Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Margin="10,95,10,10" AutoGenerateColumns="False" BeginningEdit="DgOverview_BeginningEdit" SelectionChanged="DgOverview_SelectionChanged" RowEditEnding="DgOverview_RowEditEnding"> <!---->

            <DataGrid.Columns>
                <DataGridTextColumn Header="ID" Binding="{Binding idzutritte, Mode=TwoWay}"/>
                <DataGridTemplateColumn Header="Kategorie" Width="*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox x:Name="cbKategorie" DropDownClosed="ComboBox_DropDownClosed_1" ItemsSource="{Binding Kategorien, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" SelectedItem="{Binding Kategorie, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"> <!---->

                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn x:Name="Firmenname" Width="*" Header="Firma" >
                  <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding FirmenList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" SelectedItem="{Binding NameFirma, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" DropDownOpened="ComboBox_DropDownOpened" DropDownClosed="ComboBox_DropDownClosed"> <!--ItemsSource="{Binding FirmenList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"-->
                                <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" TextAlignment="Center" Margin="-5,2,0,0"/>
                                    <!-- Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}-->
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                     </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="Besuchername" Width="*" Header="Besucher" >
                <DataGridTemplateColumn.CellTemplate>
                    <DataTemplate>
                        <ComboBox ItemsSource="{Binding BesucherList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" SelectedItem="{Binding NameBesucher, Mode=OneWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}" DropDownOpened="ComboBox_Besucher_DropDownOpened_1" DropDownClosed="ComboBox_Besucher_DropDownClosed_2">
                            <!--ItemsSource="{Binding FirmenList, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}}"-->
                            <ComboBox.ItemTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding}" TextAlignment="Center" Margin="-5,2,0,0"/>
                                    <!-- Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type local:MainWindow}}-->
                                </DataTemplate>
                            </ComboBox.ItemTemplate>
                        </ComboBox>
                    </DataTemplate>
                </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="Ankunft" Width="*" Header="Ankunft">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Button Content="Ankunft jetzt" HorizontalAlignment="Center" VerticalAlignment="Center" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Width="150" Height="NaN" Click="Button_Click">                                
                            </Button>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            <DataGridTextColumn Binding="{Binding Zutritt, StringFormat=\{0:dd.MM.yyyy HH:mm\}}" ClipboardContentBinding="{x:Null}" Header="Ankunft Zeitstempel" Width="*"/> <!---->

                <DataGridTextColumn  Binding="{Binding Pruefung_Zutritt}" ClipboardContentBinding="{x:Null}" Header="Prüfung (Zutritt)" Width="*">
                   <DataGridTextColumn.ElementStyle>
                            <Style TargetType="{x:Type TextBlock}">
                        <Setter Property="Background" Value="{Binding Pruefung_Zutritt, Converter={StaticResource ConvertToBack}}"/>

                    </Style>
                        </DataGridTextColumn.ElementStyle>                           
                </DataGridTextColumn>   
                <DataGridTextColumn Binding="{Binding Pruefung_Einweisung}" ClipboardContentBinding="{x:Null}" Header="Prüfung (Einweisung)" Width="*"><!---->
            <DataGridTextColumn.ElementStyle>
                <Style TargetType="{x:Type TextBlock}">
                    <Setter Property="Background" Value="{Binding Pruefung_Einweisung, Converter={StaticResource ConvertToBack}}"/>
                </Style>
            </DataGridTextColumn.ElementStyle>
            </DataGridTextColumn>
            </DataGrid.Columns>
        </DataGrid>
        <TextBox HorizontalAlignment="Left" Height="23" Margin="10,60,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="120"/>
        <Button x:Name="btnSearch" Content="Suchen" HorizontalAlignment="Left" Margin="135,60,0,0" VerticalAlignment="Top" Width="75" Height="23" Padding="1,0,1,1"/>
        <Button x:Name="btnManageUsers" Content="Manage Users" Margin="0,10,10,0" VerticalAlignment="Top" Click="BtnManageUsers_Click" HorizontalAlignment="Right" Width="87" Visibility="Collapsed"/>
        <TextBlock HorizontalAlignment="Left" Margin="10,44,0,0" TextWrapping="Wrap" Text="Suche:" VerticalAlignment="Top"/>
        <Button x:Name="btnCreateFirma" Content="Firmen verwalten" Margin="0,38,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="157" Visibility="Collapsed" Click="BtnCreateFirma_Click"/>
        <Button x:Name="btnCreateVisitor" Content="Besucher verwalten" Margin="0,63,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="157" Visibility="Collapsed" Click="BtnCreateVisitor_Click"/>
        <Button x:Name="btnNew" Content="Firma/Besucher kommt an" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top" Width="200" Click="BtnNew_Click"/>

    </Grid>
</Window>
