<Window x:Class="SlnMesnac.WPF.Views.FormulaWindow"
        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:SlnMesnac.WPF.Views" WindowStartupLocation="CenterScreen"
        xmlns:converters="clr-namespace:SlnMesnac.WPF.ConvertTo"
        mc:Ignorable="d" Background="#1157b9"
        Title="配方管理" Height="1000" Width="1200">
    <Window.Resources>
        <converters:BooleanToOppositeBooleanConverter x:Key="InverseBooleanConverter" />
        <Style x:Key="DataGridTextColumnCenterSytle" TargetType="{x:Type TextBlock}">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="FontSize" Value="18"/>
        </Style>
        <Style TargetType="DataGrid">
            <!--网格线颜色-->
            <Setter Property="CanUserResizeColumns" Value="false"/>
            <Setter Property="Background" Value="#1152AC" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Foreground" Value="White"/>
            <Setter Property="HorizontalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#4285DE"/>
                </Setter.Value>
            </Setter>
            <Setter Property="VerticalGridLinesBrush">
                <Setter.Value>
                    <SolidColorBrush Color="#1152AC"/>
                </Setter.Value>
            </Setter>
        </Style>
        <!--列头标题栏样式-->
        <Style TargetType="DataGridColumnHeader">

            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="BorderBrush" Value="#dddddd" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="18"/>
            <Setter Property="Background" Value="#4285DE"/>
            <Setter Property="Foreground" Value="White"/>
        </Style>

        <!--单元格样式-->
        <Style TargetType="DataGridCell">
            <Setter Property="FocusVisualStyle" Value="{x:Null}" />
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="BorderBrush" Value="#4285DE" />
            <Setter Property="Height" Value="40"/>
            <Setter Property="FontSize" Value="12"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <Grid Background="{TemplateBinding Background}" >
                            <ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
            <Style.Triggers>
                <Trigger Property="IsSelected" Value="True">
                    <Setter Property="Background" Value="#4285DE"/>
                    <Setter Property="Foreground" Value="#dddddd"/>
                </Trigger>
            </Style.Triggers>

        </Style>
    </Window.Resources>
    <Border Grid.Row="1" Grid.Column="1" BorderBrush="#0288d1" BorderThickness="2" CornerRadius="5" Background="Transparent" Margin="5">
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
                <RowDefinition Height="6*"/>
            </Grid.RowDefinitions>
            <StackPanel Orientation="horizontal" Grid.Row="0" HorizontalAlignment="Left" VerticalAlignment="Center">
                <Label Content="相机模版Key:"  FontSize="20" Foreground="White"/>
                <TextBox Text="{Binding KeyTxt,Mode=TwoWay}" Width="100" FontSize="20" Foreground="White" Margin="0 0 30 0" />
                <Label Content="冰箱型号参数:" Width="130" FontSize="20" Foreground="White"/>
                <TextBox Text="{Binding ValueTxt,Mode=TwoWay}" Width="300" FontSize="20" Foreground="White" Margin="0 0 30 0" />
                <Button
                            Content="添  加"  Command="{Binding AddCommand}"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="LimeGreen" Margin="0 0 30 0"/>
                <Button
                            Content="修  改"  Command="{Binding UpdateCommand}"
                            Style="{StaticResource MaterialDesignRaisedSecondaryDarkButton}" Background="DeepSkyBlue" Margin="0 0 30 0"/>
            </StackPanel>
            <UniformGrid Grid.Row="1">
                <DataGrid x:Name="listDataGrid"  Grid.Row="0" ItemsSource="{Binding LogoFormulaDataGrid}" Background="#00000000" 
                       ColumnHeaderHeight="35"   Height="{Binding Path=ActualHeight, ElementName=ScanPanel}" 
                      RowHeight="50" AutoGenerateColumns="False" RowHeaderWidth="0"  FontSize="20"
                      GridLinesVisibility="None" ScrollViewer.HorizontalScrollBarVisibility="Auto"  LoadingRow="dgvMH_LoadingRow"
                      ScrollViewer.VerticalScrollBarVisibility="Auto"  BorderThickness="0" CanUserAddRows="False" SelectionMode="Single" IsReadOnly="True"
                      Foreground="White" SelectedItem="{Binding SelectedRow}" >
                    <!--修改选中字体颜色-->
                    <DataGrid.Columns>
                        <DataGridTemplateColumn  Width="55" Header="序号"  >
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=FindAncestor,AncestorType={x:Type DataGridRow}}, Path=Header}" FontSize="18" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0"></TextBlock>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                        <DataGridTextColumn Binding="{Binding Key}" Header="相机模版Key" Width="*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}"/>
                        <DataGridTextColumn Binding="{Binding Value}" Header="冰箱型号参数" Width="2*" ElementStyle="{StaticResource  DataGridTextColumnCenterSytle}" />
                       
                        <DataGridTemplateColumn Header="操作" Width="1.5*">
                            <DataGridTemplateColumn.CellTemplate>
                                <DataTemplate>
                                    <Button Content="删除" Background="Red" Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"
                    CommandParameter="{Binding Key}"/>
                                </DataTemplate>
                            </DataGridTemplateColumn.CellTemplate>
                        </DataGridTemplateColumn>
                    </DataGrid.Columns>
                </DataGrid>


            </UniformGrid>


        </Grid>
    </Border>
</Window>
