<Page x:Class="SASDesktop.Views.Transport.List"
      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" 
      xmlns:local="clr-namespace:SASDesktop.Views.Transport" xmlns:transport="clr-namespace:SASDesktop.ViewModels.Transport" d:DataContext="{d:DesignInstance Type=transport:List}"
      mc:Ignorable="d"
      xmlns:root="clr-namespace:SASDesktop"
      d:DesignHeight="600" d:DesignWidth="800"
      Title="Список ТС">
    <!--Страница просмотра всех транспортных средств-->
    <ScrollViewer>
        <StackPanel
            CanVerticallyScroll="True"
            Style="{StaticResource FormContainer}">

            <!--Заголовок страницы-->
            <TextBlock 
                HorizontalAlignment="Center"
                Style="{StaticResource H2}"
                Text="Список транспортных средств"/>

            <!--Кнопки управления-->
            <StackPanel Orientation="Horizontal">
                <Button
                    Content="Добавить"
                    Style="{StaticResource StandartButton}"
                    Command="{Binding Source={x:Static root:Navigation.ToTransportCreate}}"/>
                <Button
                    Content="Редактировать"
                    Style="{StaticResource StandartButton}"
                    Command="{Binding EditCmd}"/>
                <Button
                    Content="Удалить"
                    Style="{StaticResource StandartButton}"
                    Command="{Binding DeleteCmd}"/>
                <Button
                    Content="Назад"
                    Style="{StaticResource StandartButton}"
                    Command="{Binding BackCmd}"/>
            </StackPanel>
            
            <!--Сам список-->
            <ListView
                ItemsSource="{Binding TransportList}"
                ScrollViewer.HorizontalScrollBarVisibility="Disabled"
                Height="400">
                <ListView.ItemsPanel>
                    <ItemsPanelTemplate>
                        <WrapPanel Orientation="Horizontal"/>
                    </ItemsPanelTemplate>
                </ListView.ItemsPanel>

                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="310">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="80"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="20"/>
                                <RowDefinition Height="20"/>
                            </Grid.RowDefinitions>

                            <TextBlock
                                Text="VIN:"
                                Grid.Column="0"
                                Grid.Row="0"/>
                            <TextBlock
                                Text="{Binding VIN}"
                                Grid.Column="1"
                                Grid.Row="0"/>

                            <TextBlock
                                Text="Основное:"
                                Grid.Column="0"
                                Grid.Row="1"/>
                            <TextBlock
                                Text="{Binding ListGeneral}"
                                Grid.Column="1"
                                Grid.Row="1"/>
                            
                            <TextBlock
                                Text="Владелец:"
                                Grid.Column="0"
                                Grid.Row="2"/>
                            <TextBlock
                                Text="{Binding CurrentOwnerText}"
                                Grid.Column="1"
                                Grid.Row="2"/>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </StackPanel>
    </ScrollViewer>
</Page>
