<Border x:Class="SparkClient.Views.Grading.GradingResult"
      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:hc="https://handyorg.github.io/handycontrol"
      xmlns:local="clr-namespace:SparkClient.Views.Grading"
      xmlns:hx="http://helix-toolkit.org/wpf/SharpDX"
      xmlns:userControl="clr-namespace:SparkClient.Views.UserControl"
      mc:Ignorable="d"
      d:DesignWidth="1920"
      d:DesignHeight="600"
   >
    <Border.Resources>
        <Style x:Key="BorderRowStyle" TargetType="Border">
            <Setter Property="CornerRadius" Value="15" />
            <Setter Property="Background" Value="#ffffff" />
            <Setter Property="Padding" Value="5 10" />
            <Setter Property="Margin" Value="2 3" />
        </Style>

        <Style x:Key="CustomDataGridRowStyle" TargetType="DataGridRow">
            <Setter Property="Background" Value="#f0f1f6"/>
            <Setter Property="Margin" Value="0,0,0,2"/>
            <Setter Property="Height" Value="50"/>
        </Style>
        
        <Style x:Key="CustomColumnHeaderStyle" TargetType="DataGridColumnHeader">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
        
        <Style x:Key="CustomDataGridCellStyle" TargetType="DataGridCell">
            <Setter Property="FocusVisualStyle" Value="{x:Null}"/>
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
        </Style>
        
        <Style x:Key="CenteredTextBlockStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="HorizontalAlignment" Value="Stretch"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
        
    </Border.Resources>
    <Grid >
        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="300" Width="5*" />
            <ColumnDefinition Width="Auto" />
            <ColumnDefinition MinWidth="300" Width="4*" />
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="10"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>

        <Border Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="3" Style="{StaticResource BorderRowStyle}">
           <Grid>
               <Grid.ColumnDefinitions>
                   <!-- 保存 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 导出 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- DS -->
                   <ColumnDefinition Width="Auto"/>
                   <ColumnDefinition Width="Auto"/>
                   <!-- 间隔 -->
                   <ColumnDefinition Width="*"/>
                   <!-- 标准 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 形状 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 管部 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 亭部 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 重量 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 切工等级 -->
                   <ColumnDefinition Width="Auto"/>
                   <!-- 对称等级 -->
                   <ColumnDefinition Width="Auto"/>
               </Grid.ColumnDefinitions>
               <!-- 保存按钮 -->
                <Button Grid.Column="0" Padding="0" Margin="10 0 0 0" Height="50" BorderThickness="0" IsEnabled="{Binding IsEnabled}"
                       Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding SaveFileCommand}">
                   <Border
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Margin="0 0 0 0"
                       Padding="10, 10"
                       Width="100" 
                       BorderThickness="0"
                       CornerRadius="20">
                       <Border.Background>
                           <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                               <GradientStop Color="#38C8BF" Offset="0"/>
                               <GradientStop Color="#1FB2A9" Offset="1"/>
                           </LinearGradientBrush>
                       </Border.Background>
                       <TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" Text="{StaticResource DiamondResultSave}" />
                   </Border>
               </Button>
               <!-- 导出按钮 -->
                <Button Grid.Column="1" Padding="0" Margin="10 0" Height="50" BorderThickness="0"  IsEnabled="{Binding IsEnabled}"
                       Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding SaveAsCommand}">
                   <Border
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Margin="0 0 0 0"
                       Padding="10, 10"
                       Width="100" 
                       BorderThickness="0"
                       CornerRadius="20">
                       <Border.Background>
                           <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                               <GradientStop Color="#40B1FF" Offset="0"/>
                               <GradientStop Color="#3C9CE6" Offset="1"/>
                           </LinearGradientBrush>
                       </Border.Background>
                       <TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" Text="{StaticResource DiamondResultExport}" />
                   </Border>
               </Button>
               <!-- DS 下拉列表 -->
               <Border Grid.Column="3" Background="#E0E2EE" Width="170" Height="40" CornerRadius="10" Margin="2,20,30,20" > 
                   <Grid Margin="-2,0,2,0">
                       <Grid.ColumnDefinitions>
                           <ColumnDefinition Width="*" />
                           <ColumnDefinition Width="Auto" />
                           <ColumnDefinition Width="Auto" />
                           <ColumnDefinition Width="*" />
                       </Grid.ColumnDefinitions>
                       <TextBlock Grid.Column="1" Text="{StaticResource DiamondResultDs}" TextAlignment="Center" VerticalAlignment="Center"
                                  FontSize="16"/>
                       <ComboBox Grid.Column="2" ItemsSource="{Binding DSList}" DisplayMemberPath="Key" SelectedValuePath="Value" 
                                 SelectedValue="{Binding DS, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" 
                                 Margin="10 0 0 0" FontSize="16" Width="80" BorderBrush="Black" BorderThickness="0" Height="30"/>
                   </Grid>
               </Border>
                <!-- 打印按钮 -->
                <Button Grid.Column="2" Padding="0" Margin="0,0,10,0" Height="50" BorderThickness="0"  IsEnabled="{Binding IsEnabled}"
                       Background="Transparent" FocusVisualStyle="{x:Null}" Command="{Binding ThermalPrintCommand}" HorizontalAlignment="Left">
                    <Border
                       HorizontalAlignment="Center"
                       VerticalAlignment="Center"
                       Margin="0 0 0 0"
                       Padding="10, 10"
                       Width="100"
                       BorderThickness="0"
                       CornerRadius="20">
                        <Border.Background>
                            <LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
                                <GradientStop Color="#C26989B7" Offset="0"/>
                                <GradientStop Color="#C26989B7" Offset="1"/>
                            </LinearGradientBrush>
                        </Border.Background>
                        <TextBlock FontSize="18" TextAlignment="Center" Foreground="#ffffff" Text="{StaticResource Print}" />
                    </Border>
               </Button>
               <!-- 卡片 -->
               <!-- 标准 -->
               <Border Grid.Column="5" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultStandard}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Standard}"
                                   FontSize="20" Foreground="#0063FF"/>
                    </Grid>
               </Border>
               <!-- 形状 -->
               <Border Grid.Column="6" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultShape}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Shape}"
                                   FontSize="20" Foreground="#0063FF"/>
                    </Grid>
               </Border>
               <!-- 冠部 -->
               <Border Grid.Column="7" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultCrown}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding CrownType}"
                                   FontSize="20" Foreground="#0063FF"/>
                    </Grid>
               </Border>
               <!-- 亭部 -->
               <Border Grid.Column="8" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultPavilion}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding PavType}"
                                   FontSize="20" Foreground="#0063FF"/>
                    </Grid>
               </Border>
               <!-- 重量 -->
               <Border Grid.Column="9" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultWeight}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding Wight}"
                                   FontSize="20" Foreground="#0063FF"/>
                    </Grid>
               </Border>
               <!-- 切工等级 -->
               <Border Grid.Column="10" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultCutGrade}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <Border Grid.Row="2" Background="#D6D8E4" CornerRadius="5" Width="100">
                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding CutLevelTotal}"
                                       FontSize="20" Foreground="Black" Padding="5"/>
                        </Border>
                    </Grid>
               </Border>
               <!-- 切工等级 -->
               <Border Grid.Column="11" Background="#EBEEF5" Width="170" Height="80" CornerRadius="10" Margin="0 0 10 0">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="Auto"/>
                            <RowDefinition Height="*"/>
                        </Grid.RowDefinitions>
                        <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultSymmetryGrade}"
                                   FontSize="20" Foreground="Black" Margin="0 0 0 5"/>
                        <Border Grid.Row="2" Background="#D6D8E4" CornerRadius="5" Width="100">
                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SymLevelTotal}"
                                       FontSize="20" Foreground="Black" Padding="5"/>
                        </Border>
                    </Grid>
               </Border>
           </Grid>
        </Border>

        <Border Grid.Row="2" Grid.Column="0" Style="{StaticResource BorderRowStyle}" >
            <DataGrid ItemsSource="{Binding DtResults,Mode=TwoWay}" FontSize="20"
                      AutoGenerateColumns="False"
                      HeadersVisibility="Column"
                      Background="Transparent"
                      BorderThickness="0"
                      CanUserSortColumns="False"
                      CanUserResizeColumns="False"
                      GridLinesVisibility="None"
                      HorizontalScrollBarVisibility="Hidden"
                      VerticalScrollBarVisibility="Hidden"
                      ScrollViewer.HorizontalScrollBarVisibility="Hidden"
                      ScrollViewer.VerticalScrollBarVisibility="Hidden"
                      FocusVisualStyle="{x:Null}"
                      IsReadOnly="True"  
                      RowStyle="{StaticResource CustomDataGridRowStyle}"
                      ColumnHeaderStyle="{StaticResource CustomColumnHeaderStyle}"
                      CellStyle="{StaticResource CustomDataGridCellStyle}">
                <DataGrid.Resources> 
                    <Style TargetType="ScrollBar">
                        <Setter Property="Visibility" Value="Collapsed"/>
                    </Style>
                </DataGrid.Resources>
                <DataGrid.Columns>
                    <DataGridTemplateColumn Header="" Width="2*" >
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
                                    <TextBlock Text="{Binding TestItemName}"
                                               HorizontalAlignment="Center"
                                               VerticalAlignment="Center"/>

                                    <Popup x:Name="RowPopup"
                                           Placement="Bottom"
                                           AllowsTransparency="True"
                                           PlacementTarget="{Binding RelativeSource={RelativeSource AncestorType=FrameworkElement}}"
                                           Visibility="Collapsed"
                                           VerticalOffset="20"
                                           HorizontalOffset="80"> 
                                        <Border Width="1500" Height="130" Background="White" CornerRadius="5" BorderThickness="1" BorderBrush="Gray">
                                            
                                            <Grid>
                                                <Grid.RowDefinitions>
                                                    <RowDefinition Height="40"/>
                                                    <RowDefinition Height="*"/>
                                                </Grid.RowDefinitions>
                                                <Button Grid.Row="0" HorizontalAlignment="Right" Margin="5" Click="CloseAllPopup_Click" Padding="0" BorderBrush="Transparent"  
                                                        Background="Transparent" BorderThickness="0">
                                                    <Image Source="pack://application:,,,/Resource/Images/UIResource/01-8.png" MouseLeave="UIElement_OnMouseLeave" MouseEnter="UIElement_OnMouseEnter" Width="30" />
                                                </Button>
                                                <Grid Grid.Row="1">
                                                    <Grid.ColumnDefinitions>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                        <ColumnDefinition Width="Auto"/>
                                                    </Grid.ColumnDefinitions>
                                                    <Border Grid.Column="0" Background="Transparent" Width="120" Height="80" CornerRadius="10" Margin="0 0 10 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.itemName}"
                                                                       FontSize="22" Foreground="Black" FontWeight="Bold" TextWrapping="Wrap" Margin="0 0 0 5"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="1" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridAvgValue}"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Avg}"
                                                                       FontSize="20" Foreground="#0063FF"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="2" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridDeviationValue}"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Dev}"
                                                                       FontSize="20" Foreground="#0063FF"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="3" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridMinValue}"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Min}"
                                                                       FontSize="20" Foreground="#0063FF"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="4" Background="#EBEEF5" Width="100" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridMaxValue}"
                                                                    FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.Max}"
                                                                    FontSize="20" Foreground="#0063FF"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="13" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridCutLevel}"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.CutLevel}"
                                                                       FontSize="20" Foreground="#0063FF"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="14" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="{StaticResource DiamondResultGridSymLevel}"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.SymLevel}"
                                                                       FontSize="20" Foreground="#0063FF"/>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="5" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="1"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item1}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="0">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="0">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="6" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="2"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item2}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="1">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="1">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="7" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="3"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item3}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="2">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="2">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="8" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="4"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 5"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item4}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="3">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="3">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="9" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="5"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item5}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="4">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="4">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="10" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="6"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item6}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="5">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="5">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="11" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="7"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item7}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="6">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="6">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                    <Border Grid.Column="12" Background="#EBEEF5" Width="90" Height="80" CornerRadius="10" Margin="0 0 5 0">
                                                        <Grid>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="Auto"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <TextBlock Grid.Row="1" TextAlignment="Center" VerticalAlignment="Center" Text="8"
                                                                       FontSize="18" Foreground="Black" Margin="0 0 0 6"/>
                                                            <TextBlock Grid.Row="2" TextAlignment="Center" VerticalAlignment="Center" Text="{Binding SelRowDataDetail.item8}"
                                                                       FontSize="20" Foreground="#0063FF">
                                                                <TextBlock.Style>
                                                                    <Style TargetType="TextBlock">
                                                                        <Setter Property="FontWeight" Value="Normal"/>
                                                                        <Style.Triggers>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MaxIndex}" Value="7">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                            <DataTrigger Binding="{Binding SelRowDataDetail.MinIndex}" Value="7">
                                                                                <Setter Property="FontWeight" Value="Bold"/>
                                                                            </DataTrigger>
                                                                        </Style.Triggers>
                                                                    </Style>
                                                                </TextBlock.Style>
                                                            </TextBlock>
                                                        </Grid>
                                                    </Border>
                                                </Grid>
                                               
                                            </Grid>
                                        </Border>
                                    </Popup>

                                    <!-- 点击区域,触发打开(或切换) Popup 事件 -->
                                    <Border x:Name="ClickArea"
                                            Background="Transparent"
                                            MouseLeftButtonUp="ClickArea_MouseLeftButtonUp"/>
                                </Grid>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <!-- 第2~5列 -->
                    <DataGridTextColumn Header="{StaticResource DiamondResultGridAvgValue}" Binding="{Binding Avg}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
                    <DataGridTextColumn Header="{StaticResource DiamondResultGridDeviationValue}" Binding="{Binding Dev}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
                    <DataGridTextColumn Header="{StaticResource DiamondResultGridMinValue}" Binding="{Binding Min}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>
                    <DataGridTextColumn Header="{StaticResource DiamondResultGridMaxValue}" Binding="{Binding Max}" Width="*" ElementStyle="{StaticResource CenteredTextBlockStyle}"/>

                    <!-- 第6列 -->
                    <DataGridTextColumn Header="{StaticResource DiamondResultGridCutLevel}" Binding="{Binding CutLevel}" Width="*">
                        <DataGridTextColumn.ElementStyle>
                            <Style TargetType="TextBlock">
                                <Setter Property="Foreground" Value="Blue"/>
                                <Setter Property="HorizontalAlignment" Value="Center"/>
                                <Setter Property="VerticalAlignment" Value="Center"/>
                            </Style>
                        </DataGridTextColumn.ElementStyle>
                    </DataGridTextColumn>
                    <!-- 第五列:SYM等级,下拉框示例,可编辑 -->
                    <DataGridTemplateColumn Width="*" Header="{DynamicResource DiamondResultGridSymLevel}">
                        <DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>

                                <ComboBox ItemsSource="{Binding GradeList}"
                                          IsEnabled="{Binding isEnabled}"
                                          DisplayMemberPath="{DynamicResource NameType}"
                                          SelectedValuePath="GRADE_ORDER"
                                          SelectedValue="{Binding SymLevel, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
                                          SelectionChanged="ChangSymLevel"
                                          FontSize="20" 
                                          Foreground="DarkSlateGray"
                                          HorizontalAlignment="Center"
                                          VerticalAlignment="Center"
                                          Width="120">
                                 
                                </ComboBox>
                            </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                    </DataGridTemplateColumn>
                    <DataGridTextColumn Header="TestItemId" Binding="{Binding TestItemId}" Visibility="Hidden"/>
                </DataGrid.Columns>
            </DataGrid>
        </Border>
        
        <GridSplitter Grid.Row="2"  Grid.Column="1" Width="5" HorizontalAlignment="Stretch" Background="Transparent"></GridSplitter>
        <Border Grid.Row="2"  Grid.Column="2" Background="White" Style="{StaticResource BorderRowStyle}">
            <Grid>
                <Grid.RowDefinitions>
                    <!-- <RowDefinition Height="50"></RowDefinition> -->
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <userControl:Viewport3D ViewportData="{Binding ViewportData}"></userControl:Viewport3D>
            </Grid>
        </Border>
    </Grid>
</Border>