<Window x:Class="Work29.ViewTasksWindow"
        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:Work29" xmlns:viewmodels="clr-namespace:Work29.ViewModels" xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
        mc:Ignorable="d"
        Title="ViewTasksWindow" Height="400" Width="800" MinHeight="400" MinWidth="800" MaxHeight="500" MaxWidth="1000">
    <Window.Resources>
        <viewmodels:ViewTasksWindowViewModel x:Key="ViewTask"/>
    </Window.Resources>
    <Window.DataContext>
        <Binding Source="{StaticResource ViewTask}"/>
    </Window.DataContext>

    <Grid Background="Black">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="8*"/>
            <RowDefinition Height="2*"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <DataGrid Grid.Row="1" ItemsSource="{Binding Tasks}" SelectedItem="{Binding Task}" Grid.ColumnSpan="3" Name="Tasks_table" AutoGenerateColumns="False" IsReadOnly="True" ScrollViewer.CanContentScroll="True" ColumnWidth="*">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Id" Binding="{Binding Id}"/>
                <DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
                <DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
                <DataGridTextColumn Header="YearOfRelease" Binding="{Binding YearOfRelease, StringFormat={}{0:yyyy}}"/>
                <DataGridTextColumn Header="LoginCreated" Binding="{Binding UserCreated.Login}"/>
                <DataGridTextColumn Header="LoginAccepted" Binding="{Binding UserAccepted.Login}"/>
                <DataGridTemplateColumn Header="StatusTask">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ComboBox DisplayMemberPath="Name"
                                      ItemsSource="{Binding StatusTasks, Source={StaticResource ViewTask}}"
                                      SelectedItem="{Binding StatusTask, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                      SelectedValue="Name">
                                <i:Interaction.Triggers>
                                    <i:EventTrigger EventName="SelectionChanged">
                                        <i:InvokeCommandAction Command="{Binding AlterStatus, Source={StaticResource ViewTask}}"/>
                                    </i:EventTrigger>
                                </i:Interaction.Triggers>
                            </ComboBox>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <Label Content="Смена статуса: " Foreground="White" FontSize="15" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Grid.Row="2"/>
        <Label Content="Поиск по логину: " Foreground="White" FontSize="15" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Column="0" Grid.Row="2"/>
        <TextBox x:Name="textbox_UserCreatedLogin" Text="{Binding UserCreatedLogin}" Grid.Row="2" HorizontalAlignment="Right" Grid.Column="0" VerticalAlignment="Center" Height="35" Width="135" FontSize="15" VerticalContentAlignment="Center"/>
        <Button Content="Поиск" Grid.Column="1" FontSize="15" Width="55" Grid.Row="2" Height="35" VerticalAlignment="Center" HorizontalAlignment="Left" Command="{Binding FindUserTask}"/>
        <Button Content="Взять задачу" Grid.Column="1" FontSize="15" Width="150" Grid.Row="0" Height="35" VerticalAlignment="Center" HorizontalAlignment="Center" Command="{Binding AcceptTask}" CommandParameter="{Binding ElementName=Tasks_table, Path=SelectedItem}"/>
        <Button Content="Выполн.задачи" Grid.Column="2" FontSize="15" Width="125" Grid.Row="0" Height="35" VerticalAlignment="Center" HorizontalAlignment="Left" Command="{Binding CompletedTasks}"/>
        <Button Content="Доступ.задачи" Grid.Column="2" FontSize="15" Width="125" Grid.Row="0" Height="35" VerticalAlignment="Center" HorizontalAlignment="Right" Command="{Binding AvailableTasks}"/>
        <Button Content="Сменить" Grid.Column="2" FontSize="15" Width="70" Grid.Row="2" Height="35" VerticalAlignment="Center" HorizontalAlignment="Right" Command="{Binding AlterStatus}" CommandParameter="{Binding ElementName=Tasks_table, Path=SelectedItem}"/>
        <Button Content="Начал.окно" Grid.Column="0" FontSize="15" Width="90" Grid.Row="0" Height="35" VerticalAlignment="Center" HorizontalAlignment="Left" Command="{Binding InitialWindow}"/>
    </Grid>
</Window>