<EgtWPFLib5:EgtCustomWindow x:Class="BeamMachiningsWindowV"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:EgtWPFLib5="clr-namespace:EgtWPFLib5;assembly=EgtWPFLib5"
                            xmlns:EgtBEAMWALL="clr-namespace:EgtBEAMWALL.ViewerOptimizer" 
                            xmlns:EgtBEAMWALLCORE="clr-namespace:EgtBEAMWALL.Core;assembly=EgtBEAMWALL.Core"
                            Title="{Binding Title}"
                            Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}"
                            WindowStyle="None" ResizeMode="NoResize"
                            Width="500" Height="450"
                            IsResizable="False"
                            IsMinimizable="False" WindowStartupLocation="CenterOwner" ShowInTaskbar="False"
                            CloseCommand="{Binding Close_Command,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">

   <Grid Margin="5,5,5,0">
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="1*"/>
         <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      
      <TabControl ItemsSource="{Binding MachiningList}"
                  SelectedItem="{Binding SelMachining}"
                  IsSynchronizedWithCurrentItem="True"
                  Margin="5,0,5,0"
                  Style="{StaticResource TabControl_OnlyHeaders}"/>

      <EgtBEAMWALLCORE:EgtDataGrid Grid.Row="1"
                ItemsSource="{Binding TableRowList}"
                SelectedIndex="{Binding SelRowIndex}"
                AutoGenerateColumns="False"
                CanUserResizeRows="False"
                SelectionMode="Single"
                ScrollViewer.CanContentScroll="True" 
                ScrollViewer.VerticalScrollBarVisibility="Auto"
                ScrollViewer.HorizontalScrollBarVisibility="Auto"
                Margin="0,0,0,5"
                BindingColumns="{Binding BeamMachiningsColumns}">
         
         <DataGrid.RowStyle>
            <Style TargetType="DataGridRow">
               <Setter Property="Height" Value="25"/>
               <Setter Property="VerticalContentAlignment" Value="Center"/>
            </Style>
         </DataGrid.RowStyle>

         <DataGrid.Resources>
            <Style x:Key="DataGridCheckBoxColumn_Style"
                   TargetType="{x:Type DataGridCell}">
               <Setter Property="Template">
                  <Setter.Value>
                     <ControlTemplate TargetType="{x:Type DataGridCell}">
                        <Grid Background="{TemplateBinding Background}">
                           <ContentPresenter VerticalAlignment="Center" />
                        </Grid>
                     </ControlTemplate>
                  </Setter.Value>
               </Setter>
            </Style>
            
            <!--Colonna On-->
            <DataGridCheckBoxColumn x:Key="colON" Binding="{Binding OnPar, UpdateSourceTrigger=PropertyChanged}"
                                    CellStyle="{StaticResource DataGridCheckBoxColumn_Style}">
               <DataGridCheckBoxColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.OnHdr,RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"/>
               </DataGridCheckBoxColumn.Header>
            </DataGridCheckBoxColumn>

            <!--Colonna Name-->
            <DataGridTemplateColumn x:Key="colNAME">
               <DataGridTemplateColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.NameHdr,RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"/>
               </DataGridTemplateColumn.Header>
               <DataGridTemplateColumn.CellEditingTemplate>
                  <DataTemplate>
                     <ComboBox IsEditable="False" 
                               SelectedItem="{Binding Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                               ItemsSource="{Binding Path=NamesList, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
                  </DataTemplate>
               </DataGridTemplateColumn.CellEditingTemplate>
               <DataGridTemplateColumn.CellTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=Name,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                VerticalAlignment="Center"
                                Margin="5,0,0,0"/>
                  </DataTemplate>
               </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>

            <!--Colonna Style-->
            <DataGridTemplateColumn x:Key="colTYPE">
               <DataGridTemplateColumn.Header>
                  <TextBlock Text="{Binding Path=DataContext.TypeHdr,RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"/>
               </DataGridTemplateColumn.Header>
               <DataGridTemplateColumn.CellEditingTemplate>
                  <DataTemplate>
                     <ComboBox IsEditable="False" 
                               SelectedItem="{Binding Type,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                               ItemsSource="{Binding Path=TypeList, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"/>
                  </DataTemplate>
               </DataGridTemplateColumn.CellEditingTemplate>
               <DataGridTemplateColumn.CellTemplate>
                  <DataTemplate>
                     <TextBlock Text="{Binding Path=Type,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
                                VerticalAlignment="Center"
                                Margin="5,0,0,0"/>
                  </DataTemplate>
               </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            
         </DataGrid.Resources>
         
      </EgtBEAMWALLCORE:EgtDataGrid>
      
      <Grid Grid.Row="2"
            Margin="0,0,0,5"
            HorizontalAlignment="Center">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="Auto"/>
         </Grid.ColumnDefinitions>

         <Button Content="/\"
                 Command="{Binding MoveRowUp_Command}"
                 Grid.Column="0"
                 Margin="0,0,2.5,0"
                 Style="{StaticResource EgtWPFLib5_InputButton}"/>
         <Button Content="\/"
                 Command="{Binding MoveRowDown_Command}"
                 Grid.Column="1"
                 Margin="2.5,0,2.5,0"
                 Style="{StaticResource EgtWPFLib5_InputButton}"/>
         <Button Content="{Binding AddRowMsg}"
                 Command="{Binding AddRow_Command}"
                 Grid.Column="2"
                 Margin="2.5,0,2.5,0"
                 Style="{StaticResource EgtWPFLib5_InputButton}"/>
         <Button Content="{Binding DeleteRowMsg}"
                 Command="{Binding DeleteRow_Command}"
                 Grid.Column="3"
                 Margin="2.5,0,2.5,0"
                 Style="{StaticResource EgtWPFLib5_InputButton}"/>
         <Button Content="{Binding SaveMsg}"
                 Command="{Binding Save_Command}"
                 Grid.Column="4"
                 Margin="2.5,0,0,0"
                 Style="{StaticResource EgtWPFLib5_InputButton}"/>

      </Grid>

   </Grid>

</EgtWPFLib5:EgtCustomWindow>
