<UserControl
    x:Class="MECF.Framework.UI.Client.RecipeEditorLib.DGExtension.DataGridRecipe"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:ExtendedGrid.Microsoft.Windows.Controls"
    xmlns:controls1="clr-namespace:OpenSEMI.Ctrlib.Controls"
    xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
    xmlns:cv="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.Converters"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:local="clr-namespace:MECF.Framework.UI.Client.RecipeEditorLib.DGExtension"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:micro="clr-namespace:Caliburn.Micro"
    xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
    d:DesignHeight="450"
    d:DesignWidth="800"
    mc:Ignorable="d">
    <UserControl.Resources>

        <!--#region Converters-->

        <converters:BoolCollapsedConverter x:Key="BoolCollapsedConverter" />
        <converters:BoolReverseConverter x:Key="boolRConverter" />
        <cv:ParamToCellTooltipConverter x:Key="CellTooltipConverter" />
        <cv:IsHighlightedToBorderThickness x:Key="IsHighlightedToBorderThickness" />
        <cv:IsHighlightedToBorderBrush x:Key="IsHighlightedToBorderBrush" />
        <cv:ParamValueDisplayConverter x:Key="ParamValueDisplayConverter" />
        <cv:PermissionToIsEnabledConverter x:Key="PermissionToIsEnabledConverter" />

        <!--#endregion-->

        <!--#region Column Header Template-->
        <DataTemplate x:Key="ColumnHeaderTemplateCommon">
            <Grid Width="320" Margin="0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="280" />
                    <ColumnDefinition Width="40" />
                </Grid.ColumnDefinitions>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <TextBlock
                    Grid.Column="0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    FontFamily="Arial"
                    FontSize="16"
                    Text="{Binding DisplayName}" />
                <TextBlock
                    Grid.Column="1"
                    Margin="0,0,0,0"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    FontFamily="Arial"
                    FontSize="16"
                    Text="{Binding UnitName}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ColumnHeaderTemplateStepNo">
            <Grid Width="320" Margin="0,5">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="280" />
                    <ColumnDefinition Width="40" />
                </Grid.ColumnDefinitions>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <TextBlock
                    Grid.Column="0"
                    HorizontalAlignment="Left"
                    VerticalAlignment="Center"
                    FontFamily="Arial"
                    FontSize="16"
                    Text="{Binding DisplayName}" />
                <CheckBox
                    Grid.Column="1"
                    Margin="0,0,0,0"
                    HorizontalAlignment="Right"
                    VerticalAlignment="Center"
                    IsChecked="{Binding DataContext.CurrentRecipe.Steps.IsAllStepsSelected, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}" />
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="ColumnHeaderTemplateExpander">
            <Border
                Width="340"
                Margin="-5,-8,-6,-8"
                Background="LightGray">
                <Expander
                    Margin="5"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"
                    HorizontalContentAlignment="Left"
                    VerticalContentAlignment="Stretch"
                    Collapsed="Expander_OnCollapsed"
                    Expanded="Expander_OnExpanded"
                    FontSize="14"
                    Header="{Binding DisplayName}"
                    IsExpanded="{Binding IsExpanded}" />
                <Border.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Border.LayoutTransform>
            </Border>
        </DataTemplate>

        <!--#endregion-->

        <Style x:Key="DoubleUpDownStyle1" TargetType="{x:Type xctk:DoubleUpDown}">
            <Setter Property="BorderThickness" Value="0" />
            <Setter Property="TextAlignment" Value="Center" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type xctk:DoubleUpDown}">
                        <xctk:WatermarkTextBox
                            x:Name="PART_TextBox"
                            MinWidth="20"
                            Padding="{TemplateBinding Padding}"
                            HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
                            AcceptsReturn="false"
                            Background="{TemplateBinding Background}"
                            BorderThickness="0"
                            ContextMenu="{TemplateBinding ContextMenu}"
                            FontFamily="{TemplateBinding FontFamily}"
                            FontSize="{TemplateBinding FontSize}"
                            FontStretch="{TemplateBinding FontStretch}"
                            FontStyle="{TemplateBinding FontStyle}"
                            FontWeight="{TemplateBinding FontWeight}"
                            Foreground="{TemplateBinding Foreground}"
                            IsReadOnly="{Binding IsReadOnly, RelativeSource={RelativeSource TemplatedParent}}"
                            SelectAllOnGotFocus="{Binding SelectAllOnGotFocus, RelativeSource={RelativeSource TemplatedParent}}"
                            Style="{StaticResource GenericTextBoxStyle}"
                            TabIndex="{TemplateBinding TabIndex}"
                            TextAlignment="{Binding TextAlignment, RelativeSource={RelativeSource TemplatedParent}}"
                            TextWrapping="NoWrap"
                            Watermark="{Binding Watermark, RelativeSource={RelativeSource TemplatedParent}}"
                            WatermarkTemplate="{Binding WatermarkTemplate, RelativeSource={RelativeSource TemplatedParent}}" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--#region Cell Templates-->

        <DataTemplate x:Key="CellTemplateDisplay">
            <Border
                BorderBrush="{Binding IsHighlighted, Mode=OneWay, Converter={StaticResource IsHighlightedToBorderBrush}}"
                BorderThickness="{Binding IsHighlighted, Mode=OneWay, Converter={StaticResource IsHighlightedToBorderThickness}}"
                IsHitTestVisible="{Binding IsEnabled}"
                PreviewMouseDown="DataGridCell_OnPreviewMouseDown"
                ToolTip="{Binding Converter={StaticResource CellTooltipConverter}}">
                <Border.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Border.LayoutTransform>
                <Border.Style>
                    <Style TargetType="Border">
                        <Setter Property="Background" Value="#00FFFFFF" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsSaved}" Value="False">
                                <Setter Property="Background" Value="{StaticResource DataGrid_BG_CellValueChangedWithoutSave}" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>
                <Border Margin="1" Background="{Binding StepBackgroundColorBrush}">
                    <TextBlock
                        Padding="5,3"
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        TextTrimming="CharacterEllipsis">
                        <TextBlock.Text>
                            <!--  是否隐藏单元格内容  -->
                            <MultiBinding Converter="{StaticResource ParamValueDisplayConverter}">
                                <Binding Path="Value" />
                                <Binding Path="Permission" />
                                <Binding Path="IsHideValue" />
                                <Binding Path="HiddenValueMasking" />
                            </MultiBinding>
                        </TextBlock.Text>
                        <TextBlock.Style>
                            <Style TargetType="TextBlock">
                                <Style.Triggers>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding IsEqualsToPrevious}" Value="False" />
                                            <Condition Binding="{Binding IsValid}" Value="False" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Foreground" Value="{StaticResource DataGrid_FG_CellValueNotValid}" />
                                    </MultiDataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding IsEqualsToPrevious}" Value="True" />
                                            <Condition Binding="{Binding IsValid}" Value="False" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Foreground" Value="{StaticResource DataGrid_FG_CellValueNotValid}" />
                                    </MultiDataTrigger>
                                    <MultiDataTrigger>
                                        <MultiDataTrigger.Conditions>
                                            <Condition Binding="{Binding IsEqualsToPrevious}" Value="False" />
                                            <Condition Binding="{Binding IsValid}" Value="True" />
                                        </MultiDataTrigger.Conditions>
                                        <Setter Property="Foreground" Value="{StaticResource DataGrid_FG_CellValueNotEquFront}" />
                                    </MultiDataTrigger>
                                </Style.Triggers>
                            </Style>
                        </TextBlock.Style>
                    </TextBlock>
                </Border>

            </Border>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateStepNo">
            <Grid>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <Border
                    Padding="5,1"
                    BorderBrush="{DynamicResource Table_BD}"
                    BorderThickness="0"
                    IsHitTestVisible="{Binding IsEnabled}">
                    <StackPanel
                        HorizontalAlignment="Center"
                        VerticalAlignment="Center"
                        Orientation="Horizontal">
                        <CheckBox
                            Margin="4"
                            IsChecked="{Binding IsChecked}"
                            Visibility="{Binding StepCheckVisibility}" />
                        <TextBlock
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"
                            FontSize="14"
                            Foreground="Black"
                            Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                            Visibility="{Binding Visible}" />
                    </StackPanel>
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding Visible}" Value="false">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsSaved}" Value="False">
                                    <Setter Property="Background" Value="{StaticResource DataGrid_BG_CellValueChangedWithoutSave}" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateReadOnly">
            <Grid>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <Border
                    Padding="1,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderThickness="0,0,1,1">
                    <TextBlock
                        Padding="5,3"
                        IsEnabled="{Binding IsEnabled}"
                        Text="{Binding Value}" />
                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateText">
            <Grid>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <Border
                    Padding="1,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderThickness="0,0,1,1"
                    IsHitTestVisible="{Binding IsEnabled}">
                    <controls1:TextBoxEx
                        Padding="5,3"
                        AllowBackgroundChange="True"
                        IsEnabled="{Binding IsEnabled}"
                        IsHitTestVisible="{Binding IsEnabled}"
                        Text="{Binding Value, Mode=TwoWay}"
                        TextSaved="{Binding IsSaved, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
                                    <Setter Property="BorderBrush" Value="DarkBlue" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
                                    <Setter Property="BorderBrush" Value="Transparent" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Visible}" Value="false">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateSets3Ratio">
            <Border IsHitTestVisible="{Binding IsEnabled}">
                <Border.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Border.LayoutTransform>
                <TextBox
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    IsEnabled="{Binding IsEnabled}"
                    IsHitTestVisible="{Binding IsEnabled}"
                    Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                    <TextBox.Style>
                        <Style BasedOn="{StaticResource GenericTextBoxStyle}" TargetType="TextBox">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsValid}" Value="False">
                                    <Setter Property="Foreground" Value="#9c0006" />
                                    <Setter Property="Background" Value="#ffc7ce" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </TextBox.Style>
                </TextBox>
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateNumber">
            <Border IsHitTestVisible="{Binding IsEnabled}">
                <Border.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Border.LayoutTransform>
                <xctk:DoubleUpDown
                    IsHitTestVisible="{Binding IsEnabled}"
                    SelectAllOnGotFocus="True"
                    ShowButtonSpinner="False"
                    Value="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, FallbackValue=0}">
                    <xctk:DoubleUpDown.Style>
                        <Style BasedOn="{StaticResource DoubleUpDownStyle1}" TargetType="xctk:DoubleUpDown">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsValid}" Value="False">
                                    <Setter Property="Foreground" Value="#9c0006" />
                                    <Setter Property="Background" Value="#ffc7ce" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </xctk:DoubleUpDown.Style>
                </xctk:DoubleUpDown>
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateNumberText">
            <Grid>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <Border
                    Padding="1,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderThickness="0,0,1,1"
                    IsHitTestVisible="{Binding IsEnabled}">
                    <controls1:TextBoxEx
                        Padding="5,3"
                        AllowBackgroundChange="True"
                        IsEnabled="{Binding IsEnabled}"
                        IsHitTestVisible="{Binding IsEnabled}"
                        MaxValue="{Binding Maximun}"
                        MinValue="{Binding Minimun}"
                        Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
                                    <Setter Property="BorderBrush" Value="DarkBlue" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
                                    <Setter Property="BorderBrush" Value="Transparent" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateComboBox">
            <Grid>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <Border
                    Padding="1,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderThickness="0,0,1,1">
                    <controls1:ComboTextBlock
                        Padding="5,3"
                        AllowBackgroundChange="True"
                        IsEditable="{Binding IsEditable}"
                        IsEnabled="{Binding IsEnabled}"
                        IsHitTestVisible="{Binding IsEnabled}"
                        IsLoopItem="{Binding IsLoopItem}"
                        ItemsSource="{Binding Options}"
                        Text="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
                                    <Setter Property="BorderBrush" Value="DarkBlue" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
                                    <Setter Property="BorderBrush" Value="Transparent" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding Visible}" Value="false">
                                    <Setter Property="Visibility" Value="Collapsed" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>

                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateComboBoxEx">
            <Border>
                <Border.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Border.LayoutTransform>
                <ComboBox
                    HorizontalContentAlignment="Center"
                    VerticalContentAlignment="Center"
                    DisplayMemberPath="DisplayName"
                    IsEditable="{Binding IsEditable}"
                    IsEnabled="{Binding IsEnabled}"
                    ItemsSource="{Binding Options}"
                    SelectedItem="{Binding Value, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged, Delay=10}" />
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplatePopSetting">
            <Grid>
                <Grid.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Grid.LayoutTransform>
                <Border
                    Padding="15,1"
                    Background="{DynamicResource Table_BG_Content}"
                    BorderThickness="0,0,1,1"
                    IsHitTestVisible="{Binding IsEnabled}">
                    <Button
                        Content="{Binding DisplayName}"
                        Foreground="Black"
                        IsEnabled="{Binding IsEnabled}"
                        IsHitTestVisible="{Binding IsEnabled}">
                        <i:Interaction.Triggers>
                            <i:EventTrigger EventName="Click">
                                <micro:ActionMessage MethodName="PopSetting">
                                    <micro:Parameter Value="{Binding Name}" />
                                    <micro:Parameter Value="{Binding}" />
                                </micro:ActionMessage>
                            </i:EventTrigger>
                        </i:Interaction.Triggers>
                    </Button>
                    <Border.Style>
                        <Style TargetType="Border">
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="True">
                                    <Setter Property="BorderBrush" Value="DarkBlue" />
                                </DataTrigger>
                                <DataTrigger Binding="{Binding IsColumnSelected}" Value="False">
                                    <Setter Property="BorderBrush" Value="Transparent" />
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </Border.Style>
                </Border>
            </Grid>
        </DataTemplate>

        <DataTemplate x:Key="CellTemplateExpander">
            <Border
                Width="Auto"
                MinWidth="90"
                Margin="0,-5"
                Background="LightGray"
                IsHitTestVisible="{Binding IsEnabled}">
                <Border.LayoutTransform>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Border.LayoutTransform>
                <TextBlock HorizontalAlignment="Left" VerticalAlignment="Center" />
                <Border.Style>
                    <Style TargetType="Border">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding Visible}" Value="false">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Border.Style>
            </Border>
        </DataTemplate>

        <!--#endregion-->

        <!--<Style TargetType="controls:DataGridCell" BasedOn="{x:Null}">
            <Setter
                Property="IsEnabled"
                Value="{Binding Permission,
                            Converter={StaticResource PermissionToIsEnabledConverter}}"/>
        </Style>-->

        <Style
            x:Key="RecipeEditorDataGrid"
            BasedOn="{x:Null}"
            TargetType="local:XDataGrid">
            <Setter Property="AutoGenerateColumns" Value="False" />
            <Setter Property="Background" Value="Transparent" />
            <Setter Property="CanUserAddRows" Value="False" />
            <Setter Property="CanUserDeleteRows" Value="False" />
            <Setter Property="CanUserReorderColumns" Value="False" />
            <Setter Property="CanUserResizeColumns" Value="False" />
            <Setter Property="CanUserResizeRows" Value="False" />
            <Setter Property="FrozenColumnCount" Value="4" />
            <Setter Property="GridLinesVisibility" Value="None" />
            <Setter Property="HeadersVisibility" Value="Column" />
            <Setter Property="SelectionUnit" Value="Cell" />
            <Setter Property="SelectionMode" Value="Single" />
            <Setter Property="UseHorizontalScrolling" Value="True" />
            <Setter Property="VerticalScrollBarVisibility" Value="Auto" />
            <Setter Property="CellStyle" Value="{x:Null}" />
            <Setter Property="Validation.ErrorTemplate" Value="{x:Null}" />
            <Setter Property="LayoutTransform">
                <Setter.Value>
                    <TransformGroup>
                        <RotateTransform Angle="-90" />
                        <ScaleTransform ScaleX="1" ScaleY="-1" />
                    </TransformGroup>
                </Setter.Value>
            </Setter>
            <Setter Property="RowStyle">
                <Setter.Value>
                    <Style TargetType="controls:DataGridRow">
                        <Setter Property="Visibility" Value="{Binding IsVisible, Converter={StaticResource BoolCollapsedConverter}}" />
                        <Setter Property="Background" Value="{StaticResource DataGrid_BG_Selected}" />
                        <Style.Triggers>
                            <MultiDataTrigger>
                                <MultiDataTrigger.Conditions>
                                    <Condition Binding="{Binding IsSelected}" Value="false" />
                                    <Condition Binding="{Binding IsProcessed}" Value="false" />
                                </MultiDataTrigger.Conditions>
                                <Setter Property="Background" Value="{StaticResource DataGrid_BG_First}" />
                            </MultiDataTrigger>
                            <DataTrigger Binding="{Binding IsSelected}" Value="True" />
                        </Style.Triggers>
                    </Style>
                </Setter.Value>
            </Setter>
        </Style>

        <!--#region Drag-to-Fill Style-->

        <SolidColorBrush x:Key="DragToFillFrameColor" Color="ForestGreen" />

        <Style
            x:Key="DragToFillThumbStyle"
            BasedOn="{x:Null}"
            TargetType="Thumb">
            <Setter Property="Height" Value="10" />
            <Setter Property="Width" Value="10" />
            <Setter Property="Background" Value="{StaticResource DragToFillFrameColor}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Rectangle Fill="{TemplateBinding Background}" StrokeThickness="0" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!--#endregion-->

    </UserControl.Resources>
    <local:XDataGrid
        x:Name="dgCustom"
        Width="{Binding Path=ActualHeight, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
        Height="{Binding Path=ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
        AllowDragToFill="{Binding AllowDragToFill, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}}"
        BeginningEdit="DgCustom_OnBeginningEdit"
        CellEditEnding="DgCustom_OnCellEditEnding"
        DragToFillAdornerColorBrush="{StaticResource DragToFillFrameColor}"
        DragToFillAdornerThumbStyle="{StaticResource DragToFillThumbStyle}"
        HeadersVisibility="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Path=ComperHeadersVisibility}"
        LoadingRow="DgCustom_OnLoadingRow"
        ScrollViewer.ScrollChanged="dgCustom_ScrollChanged"
        Style="{StaticResource RecipeEditorDataGrid}"
        UnloadingRow="DgCustom_OnUnloadingRow" />
</UserControl>
