<UserControl x:Class="OnlyProdFeatureListV"
             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.BTLFeatureVMList, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdFeatureListV}}}"
                                SelectedItem="{Binding Tag.SelBTLFeatureVM, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdFeatureListV}}}"
                                SelectionMode="Single"
                                Margin="0,0,0,5"
                                IsEnabled="{Binding FeatureList_IsEnabled}"
                                BindingColumns="{Binding FeatureColumns}"
                                AlternatingRowBackground="{StaticResource BeamWall_LinkWater}"
                                AlternationCount="2"
                                ColumnHeaderBackground="{StaticResource BeamWall_Keppel}"
                                ColumnHeaderForeground="{StaticResource BeamWall_White}"
                                ColumnHeaderHorizontalContentAlignment="Center"
                                ColumnHeaderFontWeight="Bold"
                                ColumnHeaderFontSize="15"
                                ColumnHeaderPadding="0,2,0,2"
                                CellStyle="{StaticResource CellDataGrid_CustomHighLight}"
                                Style="{StaticResource DataGrid_OnlyProd}">

      <DataGrid.Resources>
         <!--DO - Abilitazione-->
         <DataGridTemplateColumn x:Key="colDO">
            <DataGridTemplateColumn.HeaderTemplate>
               <DataTemplate>
                  <CheckBox IsChecked="{Binding Path=Tag.bDOALL, RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdFeatureListV}}}"
                            VerticalAlignment="Center"/>
               </DataTemplate>
            </DataGridTemplateColumn.HeaderTemplate>
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <CheckBox IsChecked="{Binding bDO, UpdateSourceTrigger=PropertyChanged}"
                            VerticalAlignment="Center"
                            HorizontalAlignment="Center"/>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--Validità feature-->
         <DataGridTemplateColumn x:Key="colCALC">
            <DataGridTemplateColumn.CellTemplate>
               <DataTemplate>
                  <Grid>
                     <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="1*"/>
                        <ColumnDefinition Width="10"/>
                     </Grid.ColumnDefinitions>
                     <Border Width="{Binding ActualHeight, RelativeSource={RelativeSource self}}"
                             Background="{Binding Calc_Background}"/>
                     <Grid Grid.Column="1">
                        <Grid.RowDefinitions>
                           <RowDefinition Height="1*"/>
                           <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Ellipse Visibility="{Binding CALC_ROT_Visibility}"
                                 Style="{StaticResource OnlyProdFeatureInPartInRawPartList_Ellipse}"/>
                        <TextBlock Grid.Row="1"
                                   Text="{Binding CALC_ERR_Letter}"
                                   Style="{StaticResource OnlyProdFeatureInPartInRawPartList_TextBlock}"/>
                     </Grid>
                  </Grid>
               </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
         </DataGridTemplateColumn>
         <!--Descrizione-->
         <DataGridTextColumn x:Key="colDESC" Binding="{Binding sDesc}">
            <DataGridTextColumn.HeaderTemplate>
               <DataTemplate>
                  <TextBlock Text="{Binding DataContext.Description_Msg,RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/>
               </DataTemplate>
            </DataGridTextColumn.HeaderTemplate>
            <DataGridTextColumn.CellStyle>
               <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource CellDataGrid_CustomHighLight}">
                  <Setter Property="Template">
                     <Setter.Value>
                        <ControlTemplate TargetType="{x:Type DataGridCell}">
                           <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Text}" 
                                      Style="{StaticResource OnlyProd_TextBlock}">
                              <TextBlock.ToolTip>
                                 <ToolTip Style="{StaticResource OnlyProd_ToolTip}">
                                    <ToolTip.Content>
                                       <StackPanel Orientation="Vertical">
                                          <TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Text}"/>
                                          <Image Source="{Binding sDrawPath}" 
                                                 Style="{StaticResource OnlyProdFeatureList_Image}"/>
                                       </StackPanel>
                                    </ToolTip.Content>
                                 </ToolTip>
                              </TextBlock.ToolTip>
                           </TextBlock>
                        </ControlTemplate>
                     </Setter.Value>
                  </Setter>
               </Style>
            </DataGridTextColumn.CellStyle>
         </DataGridTextColumn>
         <!-- Menu' tasto destro -->
         <ContextMenu x:Key="RowMenu" ItemsSource="{Binding MenuList}">
            <ContextMenu.ItemContainerStyle>
               <Style TargetType="MenuItem">
                  <Setter Property="Command" Value="{Binding MenuItem_Command}"/>
                  <Setter Property="Header" Value="{Binding sMsg}"/>
               </Style>
            </ContextMenu.ItemContainerStyle>
         </ContextMenu>
      </DataGrid.Resources>
      <DataGrid.InputBindings>
         <KeyBinding Key="Delete" Command="{Binding Tag.SelBTLFeatureVM.DeleteFeature_Command,
                                                    RelativeSource={RelativeSource AncestorType={x:Type EgtBEAMWALL:OnlyProdFeatureListV}}}" />
      </DataGrid.InputBindings>
      <DataGrid.RowStyle>
         <Style TargetType="DataGridRow" BasedOn="{StaticResource RowDataGrid_CustomHighLight}">
            <Setter Property="ContextMenu" Value="{StaticResource RowMenu}" />
            <EventSetter Event="PreviewMouseDown" Handler="FeatureList_PreviewMouseDown"/>
         </Style>
      </DataGrid.RowStyle>

   </EgtBEAMWALLCORE:EgtDataGrid>

</UserControl>
