<Window x:Class="XLAB.PlanningEditWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="{Binding Title}"
        Height="360"
        Width="980"
        MinHeight="360"
        MinWidth="860"
        WindowStartupLocation="CenterOwner">
    <Grid Margin="16">
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="220" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="*" />
            </Grid.RowDefinitions>

            <TextBlock Grid.Row="0"
                       Grid.Column="0"
                       Margin="0,0,12,8"
                       VerticalAlignment="Center"
                       Text="Прибор (EKZ)" />
            <ComboBox Grid.Row="0"
                      Grid.Column="1"
                      Margin="0,0,0,8"
                      ItemsSource="{Binding InstrumentItems}"
                      SelectedValue="{Binding SelectedInstrumentId}"
                      SelectedValuePath="Id"
                      DisplayMemberPath="DisplayName"
                      IsTextSearchEnabled="True" />

            <TextBlock Grid.Row="1"
                       Grid.Column="0"
                       Margin="0,0,12,8"
                       VerticalAlignment="Center"
                       Text="Период (TPRMCP)" />
            <ComboBox Grid.Row="1"
                      Grid.Column="1"
                      Margin="0,0,0,8"
                      ItemsSource="{Binding TemplateItems}"
                      SelectedValue="{Binding SelectedTemplateId}"
                      SelectedValuePath="Id"
                      DisplayMemberPath="DisplayName"
                      IsTextSearchEnabled="True" />

            <TextBlock Grid.Row="2"
                       Grid.Column="0"
                       Margin="0,0,12,8"
                       VerticalAlignment="Center"
                       Text="Плановая дата" />
            <DatePicker Grid.Row="2"
                        Grid.Column="1"
                        Margin="0,0,0,8"
                        HorizontalAlignment="Left"
                        SelectedDate="{Binding PlannedOn, Mode=TwoWay}"
                        SelectedDateFormat="Short" />

            <TextBlock Grid.Row="3"
                       Grid.Column="0"
                       Margin="0,0,12,8"
                       VerticalAlignment="Top"
                       Text="Выбранный прибор" />
            <TextBlock Grid.Row="3"
                       Grid.Column="1"
                       Margin="0,0,0,8"
                       TextWrapping="Wrap"
                       Text="{Binding SelectedInstrumentDescription}" />

            <TextBlock Grid.Row="4"
                       Grid.Column="0"
                       Margin="0,0,12,0"
                       VerticalAlignment="Top"
                       Text="Пояснение" />
            <TextBlock Grid.Row="4"
                       Grid.Column="1"
                       Foreground="DimGray"
                       TextWrapping="Wrap"
                       Text="{Binding TemplateWarningMessage}" />
        </Grid>

        <DockPanel Grid.Row="1"
                   Margin="0,12,0,0">
            <TextBlock DockPanel.Dock="Left"
                       VerticalAlignment="Center"
                       Foreground="Firebrick"
                       Text="{Binding ValidationMessage}" />
            <StackPanel DockPanel.Dock="Right"
                        Orientation="Horizontal">
                <Button Width="100"
                        Margin="0,0,8,0"
                        IsDefault="True"
                        Command="{Binding ConfirmCommand}"
                        Content="Сохранить" />
                <Button Width="90"
                        Command="{Binding CancelCommand}"
                        Content="Отмена" />
            </StackPanel>
        </DockPanel>
    </Grid>
</Window>
