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

   <EgtBEAMWALLCORE:EgtDataGrid ItemsSource="{Binding Tag.MachGroupVMList,
                                   RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"
                                SelectedItem="{Binding Tag.SelectedMachGroup,
                                                       RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"
                                AutoGenerateColumns="False"
                                CanUserDeleteRows="False"
                                CanUserResizeRows="False"
                                SelectionMode="Single"
                                ScrollViewer.CanContentScroll="True" 
                                ScrollViewer.VerticalScrollBarVisibility="Auto"
                                ScrollViewer.HorizontalScrollBarVisibility="Auto"
                                Margin="0,0,0,5"
                                BindingColumns="{Binding RawPartColumns}"
                                BeginningEdit="RawPartList_BeginningEdit"
                                Style="{StaticResource DataGrid_CustomHighLight}">
      <DataGrid.Resources>
         <!--ID - Id gruppo-->
         <DataGridTextColumn x:Key="colNAME" Binding="{Binding Name}"
                             SortMemberPath="nName">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.ID_Msg, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.CellStyle>
               <Style TargetType="{x:Type DataGridCell}">
                  <Setter Property="BorderBrush" Value="{Binding Search_Background}"/>
                  <Setter Property="BorderThickness" Value="2"/>
                  <Style.Triggers>
                     <Trigger Property="IsSelected" Value="True">
                        <Setter Property="Foreground" Value="Blue" />
                     </Trigger>
                  </Style.Triggers>
               </Style>
            </DataGridTextColumn.CellStyle>
         </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>
         <!--STARTCUT - Ritaglio iniziale-->
         <DataGridTextColumn x:Key="colSTARTCUT" Binding="{Binding sStartCut}" SortMemberPath="dStartCut">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding Path=DataContext.StartOffset_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--W - Larghezza-->
         <DataGridTextColumn x:Key="colW" Binding="{Binding sW}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.W_Msg,
                                          RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--H - Altezza-->
         <DataGridTextColumn x:Key="colH" Binding="{Binding sH}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.H_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--L - Lunghezza-->
         <DataGridTextColumn x:Key="colL" Binding="{Binding sL}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.L_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--PosZ - Posizione in Z-->
         <DataGridTextColumn x:Key="colPOSZ" Binding="{Binding sPosZ}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.PosZ_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
            <DataGridTextColumn.EditingElementStyle>
               <Style TargetType="{x:Type TextBox}">
                  <Setter Property="Foreground" Value="Blue" />
               </Style>
            </DataGridTextColumn.EditingElementStyle>
         </DataGridTextColumn>
         <!--MAT - Materiale-->
         <DataGridTextColumn x:Key="colMATERIAL" Binding="{Binding sMATERIAL}">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.Material_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--% - % utilizzo-->
         <DataGridTextColumn x:Key="colUSAGE" Binding="{Binding sUsage}" SortMemberPath="dUsage">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.Used_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
         <!--S - Scarti-->
         <DataGridTextColumn x:Key="colWASTE" Binding="{Binding sWaste}" SortMemberPath="dWaste">
            <DataGridTextColumn.Header>
               <TextBlock Text="{Binding Path=DataContext.Waste_Msg,
                                         RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
            </DataGridTextColumn.Header>
         </DataGridTextColumn>
      </DataGrid.Resources>
      <DataGrid.InputBindings>
         <KeyBinding Key="Delete" Command="{Binding Tag.SelectedMachGroup.DeleteMachGroup_Command,
                                                    RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:RawPartListV}}}"/>
      </DataGrid.InputBindings>
      <DataGrid.RowStyle>
         <Style TargetType="DataGridRow" BasedOn="{StaticResource RowDataGrid_CustomHighLight}">
            <Setter Property="Background" Value="{Binding Background}"/>
            <EventSetter Event="PreviewMouseDown" Handler="RawPartRow_PreviewMouseDown"/>
         </Style>
      </DataGrid.RowStyle>

   </EgtBEAMWALLCORE:EgtDataGrid>

</UserControl>
