<Window x:Class="DataGrid.DataGridAddProperties"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:vm="clr-namespace:DataGrid"
        Title="DataGrid" Height="300" Width="562">
    <Window.DataContext>
        <vm:Employees/>
    </Window.DataContext>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <CheckBox Content="Czy grupować obecnych" Margin="12,12,-12,0" Checked="CheckBox_Checked" Unchecked="CheckBox_Unchecked" />
        <DataGrid Grid.Row="1" FrozenColumnCount="2" SelectionMode="Extended" SelectionUnit="CellOrRowHeader" AlternatingRowBackground="LightGray"  AlternationCount="2"  AutoGenerateColumns="False" ItemsSource="{Binding}"  Margin="5,15,12,35" GridLinesVisibility="None">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Imię" Binding="{Binding Path=Name}" />
                <DataGridTextColumn Header="Nazwisko" Binding="{Binding Path=Surname}" />
                <DataGridTextColumn Header="Stanowisko" Binding="{Binding Path=Position}" />
                <DataGridTextColumn Header="E-mail" Binding="{Binding Path=Email}" />
                <DataGridCheckBoxColumn Header="Obecny" IsReadOnly="True" Binding="{Binding Path=IsPresent}" />
                <DataGridTemplateColumn Header="Zdjęcie" MaxWidth="40" IsReadOnly="True">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Image Source="{Binding Path=Picture}" />
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
            <DataGrid.RowDetailsTemplate>
                <!--dodatkowe informacje pod rekordem - np. wizytówka-->
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Margin="10" FontWeight="Bold" Foreground="Gray" Text="{Binding Path=Name}"/>
                        <TextBlock Margin="10" FontWeight="Bold" Foreground="Gray" Text="{Binding Path=Surname}"/>
                        <TextBlock Margin="10" FontWeight="Bold" Foreground="#FF2BB182" Text="Telefon: brak informacji w bazie"/>
                    </StackPanel>
                </DataTemplate>
            </DataGrid.RowDetailsTemplate>
            <DataGrid.GroupStyle>
                <GroupStyle>
                    <GroupStyle.ContainerStyle>
                        <Style TargetType="{x:Type GroupItem}">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type GroupItem}">
                                        <Expander IsExpanded="True" BorderBrush="Silver">
                                            <ItemsPresenter />
                                            <Expander.Header>
                                                <StackPanel Orientation="Horizontal">
                                                    <CheckBox IsChecked="{Binding Path=Name, Mode=OneWay}" 
                                 Margin="10,0,0,0"/>
                                                    <TextBlock  Margin="50,0,0,0" FontWeight="Bold" 
                                 Text="{Binding Path=ItemCount}"/>
                                                </StackPanel>
                                            </Expander.Header>
                                        </Expander>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </Style>
                    </GroupStyle.ContainerStyle>
                </GroupStyle>
            </DataGrid.GroupStyle>
        </DataGrid>
    </Grid>
</Window>
