<EgtWPFLib5:EgtCustomWindow x:Class="EgtManageFileDialogV"
                            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"
                            Title="{Binding sTitle}"
                            WindowStartupLocation="CenterOwner"
                            WindowStyle="None" ResizeMode="NoResize" 
                            IsMinimizable="False" ShowInTaskbar="False"
                            Height="500" Width="800"
                            Style="{DynamicResource {x:Type EgtWPFLib5:EgtCustomWindow}}">

   <Grid Margin="5,5,5,0">
      <Grid.RowDefinitions>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="1*"/>
         <RowDefinition Height="Auto"/>
         <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <Grid Margin="5,5,5,0">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="Auto"/>
         </Grid.ColumnDefinitions>
         <Button Command="{Binding GoBack_Command}"
                 Style="{StaticResource RightPanel_Button}">
            <Image Source="\Resources\EgtDialog\Restore.png"
                   Style="{StaticResource Button_Image}"/>
         </Button>
         <TextBlock Grid.Column="1"
                    Margin="5"
                    Text="{Binding sSelPath}"
                    HorizontalAlignment="Left"
                    Style="{StaticResource DialogWindow_TextBlock}"/>
         <ComboBox Grid.Column="2"
                   HorizontalAlignment="Right"
                   IsSynchronizedWithCurrentItem="True"
                   ItemsSource="{Binding ViewModeList}"
                   SelectedItem="{Binding SelViewMode}"
                   Margin="2.5,5,2.5,5"
                   Style="{StaticResource RightPanel_ComboBox}"/>
      </Grid>
      <Grid Grid.Row="1"
            Margin="5,5,5,0">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="4*"/>
         </Grid.ColumnDefinitions>
         <TreeView x:Name="FileTree" 
                   ItemsSource="{Binding RootList}"                   
                   Margin="10"
                   FontSize="15"
                   BorderBrush="White">
            <TreeView.Resources>
               <HierarchicalDataTemplate DataType="{x:Type EgtWPFLib5:EgtFolder}" 
                                         ItemsSource="{Binding TreeItemList_View}">
                  <StackPanel Orientation="Horizontal">
                     <Image Source="{Binding sIconSource}"
                            Height="15"
                            Style="{StaticResource Button_Image}"/>
                     <TextBlock Text="{Binding sName}"
                                Style="{StaticResource DialogWindow_TextBlock}"/>
                  </StackPanel>
               </HierarchicalDataTemplate>
               <DataTemplate DataType="{x:Type EgtWPFLib5:EgtItem}">
                  <StackPanel Orientation="Horizontal">
                     <Image Source="{Binding sIconSource}"
                            Height="15"
                            Style="{StaticResource Button_Image}"/>
                     <TextBlock Text="{Binding sName}"
                                Style="{StaticResource DialogWindow_TextBlock}"/>
                  </StackPanel>
               </DataTemplate>
            </TreeView.Resources>
            <TreeView.ItemContainerStyle>
               <Style TargetType="{x:Type TreeViewItem}">
                  <Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}"/>
                  <Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/>
               </Style>
            </TreeView.ItemContainerStyle>
         </TreeView>
         <TabControl Grid.Column="1"
                     Background="Transparent"
                     BorderBrush="White"
                     BorderThickness="0"
                     SelectedIndex="{Binding nSelTab}">
            <TabControl.ItemContainerStyle>
               <Style TargetType="{x:Type TabItem}">
                  <Setter Property="Visibility" Value="Collapsed"/>
               </Style>
            </TabControl.ItemContainerStyle>
            <TabItem Header="LISTBOX">
               <ListBox x:Name="FileList" 
                        Grid.Row="1"
                        Margin="5,5,5,5"
                        BorderBrush="White"
                        IsSynchronizedWithCurrentItem="True"
                        ItemsSource="{Binding SelTreeItem.FolderList, Mode=TwoWay}"
                        SelectedItem="{Binding ItemSelected, Mode=TwoWay}">
                  <ListBox.Resources>
                     <DataTemplate x:Key="ListTemplateView" 
                                   DataType="{x:Type EgtWPFLib5:EgtDirectory}">
                        <Grid Margin="5,5,5,0"
                              Height="20">
                           <Grid.ColumnDefinitions>
                              <ColumnDefinition Width="Auto"/>
                              <ColumnDefinition Width="Auto"/>
                           </Grid.ColumnDefinitions>
                           <Image Source="{Binding sIconSource}"
                                  Height="15"
                                  Style="{StaticResource Button_Image}"/>
                           <TextBlock Grid.Column="1"
                                      Text="{Binding sName}"
                                      Style="{StaticResource DialogWindow_TextBlock}"/>
                        </Grid>
                     </DataTemplate>
                     <DataTemplate x:Key="TilesTemplateView"
                                   DataType="{x:Type EgtWPFLib5:EgtDirectory}">
                        <Grid Margin="5,5,5,0"
                              Height="50"
                              Width="250">
                           <Grid.ColumnDefinitions>
                              <ColumnDefinition Width="Auto"/>
                              <ColumnDefinition Width="1*"/>
                           </Grid.ColumnDefinitions>
                           <Image Source="{Binding sIconSource}"
                                  Style="{StaticResource Button_Image}"/>
                           <UniformGrid Grid.Column="1"
                                        Rows="3"
                                        Margin="2.5,0,2.5,5">
                              <TextBlock TextAlignment="Left"
                                         Text="{Binding sName}"
                                         HorizontalAlignment="Left"
                                         Style="{StaticResource DialogWindow_TextBlock}"/>
                              <TextBlock TextAlignment="Left"
                                         Text="{Binding ghTypeItem}"
                                         HorizontalAlignment="Left"
                                         Style="{StaticResource DialogWindow_TextBlock}"/>
                              <TextBlock TextAlignment="Left"
                                         Text="{Binding sDimension}"
                                         HorizontalAlignment="Left"
                                         Style="{StaticResource DialogWindow_TextBlock}"/>
                           </UniformGrid>
                        </Grid>
                     </DataTemplate>
                     <DataTemplate x:Key="ContentTemplateView"
                                   DataType="{x:Type EgtWPFLib5:EgtDirectory}">
                        <Grid Margin="5,5,5,0"
                              Height="50">
                           <Grid.RowDefinitions>
                              <RowDefinition Height="1*"/>
                              <RowDefinition Height="Auto"/>
                           </Grid.RowDefinitions>
                           <Grid>
                              <Grid.ColumnDefinitions>
                                 <ColumnDefinition Width="Auto"/>
                                 <ColumnDefinition Width="1*"/>
                                 <ColumnDefinition Width="1*"/>
                              </Grid.ColumnDefinitions>
                              <Image Source="{Binding sIconSource}"
                                     Style="{StaticResource Button_Image}"/>
                              <UniformGrid Grid.Column="1"
                                           Rows="2"
                                           Margin="2.5,0,2.5,5">
                                 <TextBlock TextAlignment="Left"
                                            HorizontalAlignment="Left"
                                            Text="{Binding sName}"
                                            Style="{StaticResource DialogWindow_TextBlock}"/>
                                 <TextBlock TextAlignment="Left"
                                            HorizontalAlignment="Left"
                                            Text="{Binding ghTypeItem}"
                                            Style="{StaticResource DialogWindow_TextBlock}"/>
                              </UniformGrid>
                              <UniformGrid Grid.Column="2"
                                           Rows="2"
                                           Margin="2.5,0,2.5,5">
                                 <TextBlock TextAlignment="Left"
                                            HorizontalAlignment="Left"
                                            Text="{Binding sLastModifyDate}"
                                            Style="{StaticResource DialogWindow_TextBlock}"/>
                                 <TextBlock TextAlignment="Left"
                                            HorizontalAlignment="Left"
                                            Text="{Binding sDimension}"
                                            Style="{StaticResource DialogWindow_TextBlock}"/>
                              </UniformGrid>
                           </Grid>
                           <Border Grid.Row="1"
                                   BorderThickness="1"
                                   BorderBrush="LightGray"/>
                        </Grid>
                     </DataTemplate>
                  </ListBox.Resources>
                  <ListBox.ItemTemplate>
                     <DataTemplate DataType="{x:Type EgtWPFLib5:EgtDirectory}">
                        <ContentControl Content="{Binding}">
                           <ContentControl.Style>
                              <Style TargetType="{x:Type ContentControl}">
                                 <Style.Triggers>
                                    <DataTrigger  Binding="{Binding DataContext.nSelTempleteListView, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}" Value="0">
                                       <Setter Property="ContentTemplate" Value="{StaticResource ListTemplateView}" />
                                    </DataTrigger>
                                    <DataTrigger  Binding="{Binding DataContext.nSelTempleteListView, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}" Value="1">
                                       <Setter Property="ContentTemplate" Value="{StaticResource TilesTemplateView}" />
                                    </DataTrigger>
                                    <DataTrigger  Binding="{Binding DataContext.nSelTempleteListView, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}" Value="2">
                                       <Setter Property="ContentTemplate" Value="{StaticResource ContentTemplateView}" />
                                    </DataTrigger>
                                 </Style.Triggers>
                              </Style>
                           </ContentControl.Style>
                        </ContentControl>
                     </DataTemplate>
                  </ListBox.ItemTemplate>
                  <ListBox.ItemContainerStyle>
                     <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
                        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
                        <EventSetter Event="MouseDoubleClick" Handler="ListBoxItem_MouseDoubleClick"/>
                     </Style>
                  </ListBox.ItemContainerStyle>
                  <ListBox.Style>
                     <Style TargetType="{x:Type ListBox}">
                        <Style.Triggers>
                           <DataTrigger Binding="{Binding DataContext.nSelTempleteListView, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"
                                        Value="0">
                              <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
                              <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled"/>
                              <Setter Property="ItemsPanel">
                                 <Setter.Value>
                                    <ItemsPanelTemplate>
                                       <WrapPanel Orientation="Vertical"/>
                                    </ItemsPanelTemplate>
                                 </Setter.Value>
                              </Setter>
                           </DataTrigger>
                           <DataTrigger Binding="{Binding DataContext.nSelTempleteListView, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"
                                        Value="1">
                              <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
                              <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                              <Setter Property="ItemsPanel">
                                 <Setter.Value>
                                    <ItemsPanelTemplate>
                                       <WrapPanel Orientation="Horizontal"/>
                                    </ItemsPanelTemplate>
                                 </Setter.Value>
                              </Setter>
                           </DataTrigger>
                           <DataTrigger Binding="{Binding DataContext.nSelTempleteListView, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"
                                        Value="2">
                              <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled"/>
                              <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
                              <Setter Property="ItemsPanel">
                                 <Setter.Value>
                                    <ItemsPanelTemplate>
                                       <StackPanel Orientation="Vertical"
                                                   HorizontalAlignment="Stretch"/>
                                    </ItemsPanelTemplate>
                                 </Setter.Value>
                              </Setter>
                           </DataTrigger>
                        </Style.Triggers>
                     </Style>
                  </ListBox.Style>
               </ListBox>
            </TabItem>
            <TabItem Header="DATAGRID">
               <DataGrid AutoGenerateColumns="False"
                         IsReadOnly="True"
                         HeadersVisibility="Column"
                         ItemsSource="{Binding SelTreeItem.FolderList, Mode=TwoWay}"
                         SelectedItem="{Binding ItemSelected}">
                  <!--   ColumnHeaderStyle="{StaticResource DataGridColumnHeader}"
                         RowStyle="{StaticResource RowDataGrid_CustomHighLight}"-->
                  <DataGrid.Columns>
                     <DataGridTemplateColumn Width="5*">
                        <DataGridTemplateColumn.HeaderTemplate>
                           <DataTemplate>
                              <TextBlock Text="{Binding DataContext.Name_Msg, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                         HorizontalAlignment="Left"/>
                           </DataTemplate>
                        </DataGridTemplateColumn.HeaderTemplate>
                        <DataGridTemplateColumn.CellTemplate>
                           <DataTemplate>
                              <Grid>
                                 <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="Auto"/>
                                    <ColumnDefinition Width="1*"/>
                                 </Grid.ColumnDefinitions>
                                 <Image Source="{Binding sIconSource}"
                                        Margin="2.5,0,2.5,0"
                                        Style="{StaticResource Button_Image}"/>
                                 <TextBlock Grid.Column="1"
                                            Text="{Binding sName}"
                                            VerticalAlignment="Center"
                                            Margin="2.5,0,0,0"/>
                              </Grid>
                           </DataTemplate>
                        </DataGridTemplateColumn.CellTemplate>
                     </DataGridTemplateColumn>
                     <DataGridTextColumn Binding="{Binding sLastModifyDate}"
                                         Width="2*">
                        <DataGridTextColumn.HeaderTemplate>
                           <DataTemplate>
                              <TextBlock Text="{Binding DataContext.LastModify_Msg, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                         HorizontalAlignment="Left"/>
                           </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                        <DataGridTextColumn.ElementStyle>
                           <Style TargetType="TextBlock">
                              <Setter Property="HorizontalAlignment" Value="Left"/>
                              <Setter Property="VerticalAlignment" Value="Center"/>
                              <Setter Property="TextAlignment" Value="Left"/>
                              <Setter Property="Padding" Value="12,6,12,6"/>
                           </Style>
                        </DataGridTextColumn.ElementStyle>
                     </DataGridTextColumn>
                     <DataGridTextColumn Binding="{Binding ghTypeItem}"
                                         Width="1*">
                        <DataGridTextColumn.HeaderTemplate>
                           <DataTemplate>
                              <TextBlock Text="{Binding DataContext.Type_Msg, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                         HorizontalAlignment="Left"/>
                           </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                        <DataGridTextColumn.ElementStyle>
                           <Style TargetType="TextBlock">
                              <Setter Property="HorizontalAlignment" Value="Left"/>
                              <Setter Property="VerticalAlignment" Value="Center"/>
                              <Setter Property="TextAlignment" Value="Left"/>
                              <Setter Property="Padding" Value="12,6,12,6"/>
                           </Style>
                        </DataGridTextColumn.ElementStyle>
                     </DataGridTextColumn>
                     <DataGridTextColumn Binding="{Binding sDimension}"
                                         Width="1*">
                        <DataGridTextColumn.HeaderTemplate>
                           <DataTemplate>
                              <TextBlock Text="{Binding DataContext.Dimension_Msg, RelativeSource={RelativeSource AncestorType=DataGrid}}"
                                         HorizontalAlignment="Left"/>
                           </DataTemplate>
                        </DataGridTextColumn.HeaderTemplate>
                        <DataGridTextColumn.ElementStyle>
                           <Style TargetType="TextBlock">
                              <Setter Property="HorizontalAlignment" Value="Right"/>
                              <Setter Property="VerticalAlignment" Value="Center"/>
                              <Setter Property="TextAlignment" Value="Right"/>
                              <Setter Property="Padding" Value="12,6,12,6"/>
                           </Style>
                        </DataGridTextColumn.ElementStyle>
                     </DataGridTextColumn>
                  </DataGrid.Columns>
                  <DataGrid.InputBindings>
                     <MouseBinding MouseAction="LeftDoubleClick" Command="{Binding DataContext.DoubleClick_Command, RelativeSource={RelativeSource AncestorType={x:Type EgtWPFLib5:EgtCustomWindow}}}"/>
                  </DataGrid.InputBindings>
               </DataGrid>
            </TabItem>
         </TabControl>
      </Grid>
      <Grid Grid.Row="2" 
            Margin="5,5,5,0">
         <Grid.ColumnDefinitions>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="1*"/>
            <ColumnDefinition Width="Auto"/>
         </Grid.ColumnDefinitions>
         <TextBlock Margin="5,5,5,5"
                    Text="{Binding FileName_Msg}"
                    HorizontalAlignment="Right"
                    Style="{StaticResource DialogWindow_TextBlock}"/>
         <TextBox Grid.Column="1"
                  Margin="2.5,2.5,2.5,5"
                  TextAlignment="Left"
                  HorizontalAlignment="Stretch"
                  Text="{Binding sSaveFileName, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}"
                  Style="{StaticResource ParameterList_TextBox}"/>
         <ComboBox Grid.Column="2"
                   IsSynchronizedWithCurrentItem="True"
                   ItemsSource="{Binding FilterList}"
                   SelectedItem="{Binding SelFilter, Mode=OneWayToSource}"
                   DisplayMemberPath="sNameExstension"
                   HorizontalAlignment="Right"
                   Margin="10,2.5,2.5,5"
                   Style="{StaticResource RightPanel_ComboBox}"/>
      </Grid>
      <UniformGrid Grid.Row="3"  
                   Rows="1"
                   Margin="2.5,0,2.5,0">
         <Button IsDefault="True"
                 Content="OK"
                 Command="{Binding Ok_Command}"
                 HorizontalAlignment="Right"
                 Margin="15,0,2.5,0"
                 Style="{StaticResource RightPanel_HalfRound_Button}"/>
         <Button Content="Cancel"
                 Command="{Binding Cancel_Command}"
                 HorizontalAlignment="Left"
                 Margin="2.5,0,0,0"
                 Style="{StaticResource RightPanel_HalfRound_Button}"/>
      </UniformGrid>
   </Grid>
</EgtWPFLib5:EgtCustomWindow>
