<Window x:Class="XLAB2.SpoiDirectoryWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Области измерений"
        Height="680"
        Width="980"
        MinHeight="520"
        MinWidth="820"
        Loaded="Window_Loaded"
        WindowStartupLocation="CenterOwner">
    <Grid Margin="12">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <DockPanel Grid.Row="0"
                   Margin="0,0,0,8">
            <StackPanel DockPanel.Dock="Left"
                        Orientation="Horizontal">
                <TextBlock Width="170"
                           VerticalAlignment="Center"
                           Text="Поиск по справочнику" />
                <TextBox Width="320"
                         Text="{Binding SearchText, UpdateSourceTrigger=PropertyChanged}" />
            </StackPanel>

            <StackPanel DockPanel.Dock="Right"
                        Orientation="Horizontal"
                        HorizontalAlignment="Right">
                <Button Width="110"
                        Margin="8,0,0,0"
                        Command="{Binding RefreshCommand}"
                        Content="Обновить" />
            </StackPanel>
        </DockPanel>

        <DataGrid Grid.Row="1"
                  ItemsSource="{Binding ItemsView}"
                  SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
                  AutoGenerateColumns="False"
                  CanUserAddRows="False"
                  IsReadOnly="True"
                  HeadersVisibility="Column">
            <DataGrid.Columns>
                <DataGridTextColumn Header="ID"
                                    Width="90"
                                    Binding="{Binding Id}" />
                <DataGridTextColumn Header="Код ОИ"
                                    Width="120"
                                    Binding="{Binding Code}" />
                <DataGridTextColumn Header="Область измерений"
                                    Width="*"
                                    Binding="{Binding Name}" />
            </DataGrid.Columns>
        </DataGrid>

        <TextBlock Grid.Row="2"
                   Margin="0,8,0,0"
                   Foreground="DimGray"
                   Text="{Binding StatusText}" />

        <StackPanel Grid.Row="3"
                    Margin="0,12,0,0"
                    Orientation="Horizontal"
                    HorizontalAlignment="Right">
            <Button Width="110"
                    Margin="0,0,8,0"
                    Command="{Binding AddCommand}"
                    Content="Добавить" />
            <Button Width="110"
                    Margin="0,0,8,0"
                    Command="{Binding EditCommand}"
                    Content="Изменить" />
            <Button Width="110"
                    Margin="0,0,8,0"
                    Command="{Binding DeleteCommand}"
                    Content="Удалить" />
            <Button Width="90"
                    IsCancel="True"
                    Content="Закрыть" />
        </StackPanel>
    </Grid>
</Window>
