<UserControl x:Class="PartInRawPartListV"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.Supervisor"
             xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core">

   <EgtBEAMWALLCORE:EgtDataGrid ItemsSource="{Binding Tag.PartVMList,
                                                      RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"
                                SelectedItem="{Binding Tag.SelPart,
                                                       RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"
                                AutoGenerateColumns="False"
                                CanUserAddRows="False"
                                CanUserDeleteRows="False"
                                CanUserResizeRows="False"
                                SelectionMode="Single"
                                ScrollViewer.CanContentScroll="True" 
                                ScrollViewer.VerticalScrollBarVisibility="Auto"
                                ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                Margin="0,0,0,5"
                                BindingColumns="{Binding PartInRawPartColumns}"
                                Style="{StaticResource DataGrid_CustomHighLight}">
      <DataGrid.Resources>
         <!--REDO - Abilitazione-->
         <DataGridCheckBoxColumn x:Key="colREDO" Binding="{Binding bDO, UpdateSourceTrigger=PropertyChanged}"/>
         <!--PDN - Nome-->
         <DataGridTextColumn x:Key="colPDN"  Binding="{Binding nPDN}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.PDN_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--Validità pezzo-->
         <DataGridTemplateColumn x:Key="colCALC">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Grid>
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="10"/>
                     </Grid.ColumnDefinitions>
                     <TextBlock Text="↓"
                                Foreground="Aqua"
                                TextAlignment="Center"
                                FontWeight="Bold"
                                FontSize="12"
                                Margin="0,-6,0,-2"
                                Visibility="{Binding CALC_FALL_Visibility}"/>
                     <Border Width="{Binding ActualHeight, RelativeSource={RelativeSource self}}"
                             Grid.Column="1"                          
                             Background="{Binding Calc_Background}"/>
                     <Grid Grid.Column="2"
                           HorizontalAlignment="Center">
                        <Grid.RowDefinitions>
                           <RowDefinition Height="1*"/>
                           <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Ellipse Width="5"
                                 Height="5"
                                 Fill="Red"
                                 Visibility="{Binding CALC_ROT_Visibility}"
                                 HorizontalAlignment="Center"/>
                        <TextBlock Grid.Row="1"
                                   Text="{Binding CALC_ERR_Letter}"
                                   Foreground="{Binding CALC_ERR_Foreground}"
                                   TextAlignment="Center"
                                   FontWeight="Bold"
                                   FontSize="12"
                                   Margin="0,-6,0,-2"/>
                     </Grid>
                  </Grid>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--Stato di produzione-->
         <DataGridTemplateColumn x:Key="colPRODUCTION">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Border Background="{Binding Production_Background}"/>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--NAM - Descrizione-->
         <DataGridTextColumn x:Key="colNAM" Binding="{Binding sNAM}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.NAM_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--W - Larghezza-->
         <DataGridTextColumn x:Key="colW" Binding="{Binding sW}" SortMemberPath="dW">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.W_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--H - Altezza-->
         <DataGridTextColumn x:Key="colH" Binding="{Binding sH}" SortMemberPath="dH">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.H_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--L - Lunghezza-->
         <DataGridTextColumn x:Key="colL" Binding="{Binding sL}" SortMemberPath="dL">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.L_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--ROT - Rotazione-->
         <DataGridTextColumn x:Key="colROT" Binding="{Binding sROT}" SortMemberPath="dROT">
            <DataGridTextColumn.Header>
               <TextBlock Text="Rotazione"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--INV - Inversione-->
         <DataGridTemplateColumn x:Key="colFLIP">
            <DataGridTemplateColumn.Header>
               <TextBlock Text="Inversione"/>
            </DataGridTemplateColumn.Header>
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <CheckBox IsChecked="{Binding bFLIP, UpdateSourceTrigger=PropertyChanged}"
                            HorizontalAlignment="Center"
                            VerticalAlignment="Center"/>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--PosX - Posizione-->
         <DataGridTextColumn x:Key="colPOSX" Binding="{Binding sPOSX, UpdateSourceTrigger=PropertyChanged}" SortMemberPath="dPOSX">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.PosX_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
         </DataGridTextColumn>
         <!--PosY - Posizione-->
         <DataGridTextColumn x:Key="colPOSY" Binding="{Binding sPOSY, UpdateSourceTrigger=PropertyChanged}" SortMemberPath="dPOSY">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.PosY_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
         </DataGridTextColumn>
         <!--Off - Offset-->
         <DataGridTextColumn x:Key="colOFFSET" Binding="{Binding sOffset}" SortMemberPath="dOffset">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.Offset_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--MAT - Materiale-->
         <DataGridTextColumn x:Key="colMATERIAL" Binding="{Binding sMATERIAL}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.MAT_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--GRP - Gruppo-->
         <DataGridTextColumn x:Key="colGROUP" Binding="{Binding sGROUP}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.GRP_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--STOREY - Sottogruppo-->
         <DataGridTextColumn x:Key="colSTOREY" Binding="{Binding sSTOREY}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.STOREY_Msg,RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:PartInRawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>

      </DataGrid.Resources>
      <DataGrid.RowStyle>
         <Style TargetType="DataGridRow" BasedOn="{StaticResource RowDataGrid_CustomHighLight}">
            <Setter Property="Background" Value="{Binding Production_Background}"/>
         </Style>
      </DataGrid.RowStyle>

   </EgtBEAMWALLCORE:EgtDataGrid>

</UserControl>
