<Window x:Class="TMC_Tool.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:TMC_Tool"
        xmlns:custom="clr-namespace:CustomControls"
        Title="TMC Object Tool" Height="700" Width="1160" SnapsToDevicePixels="True"
        Background="#FF333333" MinHeight="400" MinWidth="720" Drop="mainWindow_DragDrop" AllowDrop="True" DragOver="mainWindow_DragOver" AllowsTransparency="True" WindowStyle="None" Closing="Window_Closing" x:Name="mainWindow" Activated="mainWindow_Activated" Loaded="mainWindow_Loaded" MouseLeftButtonDown="mainWindow_MouseLeftButtonDown">
  <Window.Resources>
    <ResourceDictionary>
      <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="Themes/MetroDark/MetroDark.MSControls.Core.Implicit.xaml"/>
        <ResourceDictionary Source="Styles.xaml"/>
        <ResourceDictionary Source="Common/CustomControls.xaml"/>
      </ResourceDictionary.MergedDictionaries>
      <Storyboard x:Key="fadeIn" Completed="FadeInAnimation_Completed">
        <ParallelTimeline>
          <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="mainWindow" From="0" To="1" Duration="0:0:0.12"/>
        </ParallelTimeline>
      </Storyboard>
      <Storyboard x:Key="fadeOut" Completed="FadeOutAnimation_Completed">
        <ParallelTimeline>
          <DoubleAnimation Storyboard.TargetProperty="Opacity" Storyboard.TargetName="mainWindow" From="1" To="0" Duration="0:0:0.12"/>
        </ParallelTimeline>
      </Storyboard>
      <RoutedCommand x:Key="Revert"/>
      <RoutedCommand x:Key="PathPaste"/>
      <SolidColorBrush x:Key="SelectedBackgroundBrush2" Color="{StaticResource Color_024}"/>
      <Style x:Key="ObjToolCellComboBoxStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource CellComboBoxStyle}">
        <EventSetter Event="SelectionChanged" Handler="ComboBox_SelectionChanged"/>
        <EventSetter Event="PreviewMouseRightButtonDown" Handler="ComboBox_MouseRightButtonDown"/>
        <Setter Property="Background" Value="{StaticResource ComboBoxBackgroundBrush}"/>
        <Style.Triggers>
          <Trigger Property="SelectedValue" Value="{x:Null}">
            <Setter Property="Visibility" Value="Collapsed"/>
          </Trigger>
          <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridCell}, Path=IsSelected}" Value="True">
            <Setter Property="Background" Value="{StaticResource TransparentBrush}"/>
          </DataTrigger>
        </Style.Triggers>
      </Style>
    </ResourceDictionary>
  </Window.Resources>
  <WindowChrome.WindowChrome>
    <WindowChrome CaptionHeight="{x:Static SystemParameters.CaptionHeight}" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" UseAeroCaptionButtons="False"/>
  </WindowChrome.WindowChrome>
  <Window.CommandBindings>
    <CommandBinding Command="ApplicationCommands.Open" CanExecute="openCommand_CanExecute" Executed="openCommand_Executed"/>
    <CommandBinding Command="ApplicationCommands.Save" CanExecute="saveCommand_CanExecute" Executed="saveCommand_Executed"/>
    <CommandBinding Command="ApplicationCommands.SaveAs" CanExecute="saveAsCommand_CanExecute" Executed="saveAsCommand_Executed"/>
    <CommandBinding Command="ApplicationCommands.Close" CanExecute="exitCommand_CanExecute" Executed="exitCommand_Executed"/>
    <CommandBinding Command="{StaticResource Revert}" CanExecute="revertCommand_CanExecute" Executed="revertCommand_Executed"/>
    <CommandBinding Command="{StaticResource PathPaste}" CanExecute="pathPasteCommand_CanExecute" Executed="pathPasteCommand_Executed"/>
  </Window.CommandBindings>
  <Window.InputBindings>
    <KeyBinding Gesture="Ctrl+Q" Command="ApplicationCommands.Close"/>
    <KeyBinding Gesture="Ctrl+O" Command="ApplicationCommands.Open"/>
    <KeyBinding Gesture="Ctrl+S" Command="ApplicationCommands.Save"/>
    <KeyBinding Gesture="Ctrl+Shift+S" Command="ApplicationCommands.SaveAs"/>
    <KeyBinding Gesture="Ctrl+V" Command="{StaticResource PathPaste}"/>
  </Window.InputBindings>
  <Border BorderThickness="1" BorderBrush="#FF666666">
    <Grid>
      <StackPanel Orientation="Horizontal" Margin="0,5,5,0" HorizontalAlignment="Right" VerticalAlignment="Top">
        <StackPanel.Resources>
          <my:EqualsToVisibleConveter x:Key="visiConverter"/>
        </StackPanel.Resources>
        <Button Content="0" Style="{DynamicResource CaptionButtonStyleKey}" Click="ButtonMinimized_Click"/>
        <Button Content="1" Style="{DynamicResource CaptionButtonStyleKey}" Click="ButtonMaximized_Click">
          <Button.Visibility>
            <Binding RelativeSource="{RelativeSource AncestorType=Window}" Path="WindowState" Mode="OneWay" Converter="{StaticResource visiConverter}">
              <Binding.ConverterParameter>
                <WindowState>Normal</WindowState>
              </Binding.ConverterParameter>
            </Binding>
          </Button.Visibility>
        </Button>
        <Button Content="2" Style="{DynamicResource CaptionButtonStyleKey}" Click="ButtonNormal_Click">
          <Button.Visibility>
            <Binding RelativeSource="{RelativeSource AncestorType=Window}" Path="WindowState" Mode="OneWay" Converter="{StaticResource visiConverter}">
              <Binding.ConverterParameter>
                <WindowState>Maximized</WindowState>
              </Binding.ConverterParameter>
            </Binding>
          </Button.Visibility>
        </Button>
        <Button Content="r" Style="{DynamicResource CaptionButtonStyleKey}" Command="ApplicationCommands.Close"/>
      </StackPanel>
      <Label x:Name="labelTitle" HorizontalAlignment="Left" Margin="3,2,0,0" VerticalAlignment="Top"/>
      <Grid Margin="5,33,5,30">
        <Grid.RowDefinitions>
          <RowDefinition Height="38"/>
          <RowDefinition Height="300*"/>
          <RowDefinition Height="120*"/>
        </Grid.RowDefinitions>
        <custom:SplitButton x:Name="btnOpen" HorizontalAlignment="Left" VerticalAlignment="Top" Width="110" Content="開く" MainButtonCommand="ApplicationCommands.Open" TabIndex="0">
          <custom:SplitButton.DropDownContextMenu>
            <ContextMenu>
              <MenuItem x:Name="cmdOpen" Header="開く" Command="ApplicationCommands.Open"/>
              <MenuItem x:Name="cmdRevert" Header="復帰" Command="{StaticResource Revert}"/>
            </ContextMenu>
          </custom:SplitButton.DropDownContextMenu>
        </custom:SplitButton>
        <Button x:Name="btnSave" Content="上書き保存" HorizontalAlignment="Left" VerticalAlignment="Top" Width="90" Command="ApplicationCommands.Save" Margin="115,0,0,0" TabIndex="1" Height="30"/>
        <Button x:Name="btnSaveAs" Content="別名で保存" HorizontalAlignment="Left" VerticalAlignment="Top" Width="90" Command="ApplicationCommands.SaveAs" Margin="210,0,0,0" TabIndex="2" Height="30"/>
        <StackPanel x:Name="panelEdit" HorizontalAlignment="Left" Margin="315,0,0,0" VerticalAlignment="Top" Orientation="Horizontal" IsEnabled="False">
          <Label x:Name="labelEdit" Content="編集" HorizontalAlignment="Left" VerticalAlignment="Top"/>
          <Button x:Name="btnEdtMtrCol" Content="MtrCol" HorizontalAlignment="Left" VerticalAlignment="Top" Width="80" Margin="5,0,0,0" TabIndex="4" Height="30" Click="btnEdtMtrCol_Click"/>
          <Button x:Name="btnEdtMatecp" Content="matecp" HorizontalAlignment="Left" VerticalAlignment="Top" Width="80" Margin="5,0,0,0" TabIndex="4" Height="30" Click="btnEdtMatecp_Click"/>
        </StackPanel>
        <CheckBox x:Name="cbKeepData" Content="保存しても元のデータの値を保持して再試行可能にする" HorizontalAlignment="Right" Margin="0,5,5,0" VerticalAlignment="Top" Padding="2,0,0,0" TabIndex="3" HorizontalContentAlignment="Right" Height="20" Width="328" IsEnabled="False"/>
        <DataGrid x:Name="dgObject" Margin="0" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" GridLinesVisibility="Horizontal" ItemsSource="{Binding ObjData}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" HeadersVisibility="Column" IsEnabled="False" TabIndex="100" HorizontalContentAlignment="Stretch" Grid.Row="1" ContextMenuOpening="dgObject_ContextMenuOpening">
          <DataGrid.Resources>
            <ResourceDictionary>
              <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource DGColumnHeaderStyle}"/>
              <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource DGCellStyle}"/>
              <Style x:Key="ObjToolCellCountStyle" TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource DGCellTextRight}">
                <Style.Triggers>
                  <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                      <Condition Binding="{Binding IsDeleted}" Value="True"/>
                      <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsReadOnly}" Value="True"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Foreground" Value="#A66"/>
                  </MultiDataTrigger>
                  <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                      <Condition Binding="{Binding IsDeleted}" Value="True"/>
                      <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/>
                      <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsReadOnly}" Value="True"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Foreground" Value="#E99"/>
                  </MultiDataTrigger>
                </Style.Triggers>
              </Style>
              <Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource CellCheckBoxStyle}"/>
              <Style x:Key="ObjToolCellGrpComboBoxStyle" TargetType="{x:Type ComboBox}" BasedOn="{StaticResource ObjToolCellComboBoxStyle}">
                <Style.Triggers>
                  <MultiDataTrigger>
                    <MultiDataTrigger.Conditions>
                      <Condition Binding="{Binding RelativeSource={RelativeSource AncestorType=DataGridCell}, Path=IsSelected}" Value="False"/>
                      <Condition Binding="{Binding Grp}" Value="-1"/>
                    </MultiDataTrigger.Conditions>
                    <Setter Property="Background" Value="#333"/>
                  </MultiDataTrigger>
                </Style.Triggers>
              </Style>
              <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource ObjToolCellComboBoxStyle}"/>
              <x:Array x:Key="VisibleTypes" Type="{x:Type my:DisplayType}">
                <my:DisplayType Type="-"/>
                <my:DisplayType Type="表示"/>
                <my:DisplayType Type="非表示"/>
                <my:DisplayType Type="眼鏡1"/>
                <my:DisplayType Type="眼鏡2"/>
              </x:Array>
              <!--<x:Array x:Key="GlassesVisibleTypes" Type="{x:Type my:DisplayType}">
                <my:DisplayType Type="-"/>
                <my:DisplayType Type="1"/>
                <my:DisplayType Type="2"/>
              </x:Array>-->
              <x:Array x:Key="TransparentTypes" Type="{x:Type my:DisplayType}">
                <my:DisplayType Type="-"/>
                <my:DisplayType Type="1"/>
                <my:DisplayType Type="2"/>
              </x:Array>
            </ResourceDictionary>
          </DataGrid.Resources>
          <DataGrid.Columns>
            <DataGridTextColumn x:Name="dgcID" Binding="{Binding ID}" Header="ID" IsReadOnly="True" Width="30"/>
            <DataGridTextColumn x:Name="dgcName" Binding="{Binding Name}" Header="オブジェクト名" IsReadOnly="True" Width="Auto" MinWidth="150" CellStyle="{StaticResource DGCellTextLeft}"/>
            <DataGridTemplateColumn x:Name="dgcToggle" Header="切替" IsReadOnly="True" Width="70">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedIndex="{Binding Toggle,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Source={StaticResource VisibleTypes}}" DisplayMemberPath="Type" IsEditable="False" Style="{StaticResource ObjToolCellGrpComboBoxStyle}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <!--<DataGridTemplateColumn x:Name="dgcGlass" Header="眼鏡" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedIndex="{Binding Glasses,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Source={StaticResource GlassesVisibleTypes}}" DisplayMemberPath="Type" IsEditable="False">
                    <ComboBox.Style>
                      <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource ObjToolCellGrpComboBoxStyle}">
                        <Setter Property="IsEnabled" Value="False"/>
                        <Style.Triggers>
                          <DataTrigger Binding="{Binding Toggle}" Value="0">
                            <Setter Property="IsEnabled" Value="True"/>
                          </DataTrigger>
                        </Style.Triggers>
                      </Style>
                    </ComboBox.Style>
                  </ComboBox>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>-->
            <!--<DataGridTextColumn x:Name="dgcVtxGrp" Binding="{Binding VtxGrp}" Header="VGrp" IsReadOnly="True" Width="45"/>-->
            <DataGridTemplateColumn x:Name="dgcVtxGrp" Header="VGrp" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding VtxGrp,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding VtxIdxGruops}" IsHitTestVisible="{Binding IsEditable}" IsEditable="False" SelectionChanged="ComboBox_SelectionChanged"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="dgcVtxCount" Binding="{Binding VtxCount}" Header="頂点数" IsReadOnly="True" Width="55" CellStyle="{StaticResource ObjToolCellCountStyle}"/>
            <DataGridTextColumn x:Name="dgcIdxCount" Binding="{Binding IdxCount}" Header="Idx数" IsReadOnly="True" Width="55" CellStyle="{StaticResource ObjToolCellCountStyle}"/>
            <DataGridTextColumn x:Name="dgcUV" Binding="{Binding UVCount}" Header="UV" IsReadOnly="True" Width="30">
              <DataGridTextColumn.CellStyle>
                <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource DGCellStyle}">
                  <Style.Triggers>
                    <DataTrigger Binding="{Binding UVCount}" Value="-1">
                      <Setter Property="Visibility" Value="Collapsed"/>
                    </DataTrigger>
                  </Style.Triggers>
                </Style>
              </DataGridTextColumn.CellStyle>
            </DataGridTextColumn>
            <DataGridTemplateColumn x:Name="dgcTex1" Header="Tex1" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Tex1,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Textures, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcTex2" Header="Tex2" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Tex2,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Textures, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcTex3" Header="Tex3" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Tex3,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Textures, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcTex4" Header="Tex4" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Tex4,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Textures, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcTexType" Header="TexType" IsReadOnly="True" Width="70">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedIndex="{Binding TexType,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding TexTypes}" IsEditable="False">
                    <ComboBox.Style>
                      <Style  TargetType="{x:Type ComboBox}" BasedOn="{StaticResource ObjToolCellComboBoxStyle}">
                        <Setter Property="HorizontalContentAlignment" Value="Left"/>
                        <Setter Property="Padding" Value="7,0"/>
                      </Style>
                    </ComboBox.Style>
                  </ComboBox>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcEnvironmentMap" Header="環境" IsReadOnly="True" Width="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding EnvironmentMap, UpdateSourceTrigger=PropertyChanged}" Click="CheckBox_Click" IsEnabled="{Binding ChangeableEnvMap}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcTransparent" Header="透明" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedIndex="{Binding Transparent,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Source={StaticResource TransparentTypes}}" DisplayMemberPath="Type" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcDoubleSided" Header="両面" IsReadOnly="True" Width="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding DoubleSided, UpdateSourceTrigger=PropertyChanged}" Click="CheckBox_Click"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcMtrCol" Header="MCol" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding MtrCol,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.MtlCols, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcMatecp" Header="mtcp" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Matecp,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Matecps, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcMcamtrl" Header="Mtrl" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Mcamtrl,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Mcamtrls, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcZ1" Header="Z1" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Z1,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Z1s, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False" Style="{StaticResource ObjToolCellGrpComboBoxStyle}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcZ2" Header="Z2" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding Z2,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.Z2s, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False" Style="{StaticResource ObjToolCellGrpComboBoxStyle}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcCastShadow" Header="影落" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding CastShadow,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.ShadowParams, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTemplateColumn x:Name="dgcReceiveShadow" Header="影受" IsReadOnly="True" Width="44">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox SelectedItem="{Binding ReceiveShadow,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.ShadowParams, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn Width="*" IsReadOnly="True" MinWidth="0"></DataGridTextColumn>
          </DataGrid.Columns>
          <DataGrid.RowStyle>
            <Style BasedOn="{StaticResource DataGridRowStyle}" TargetType="DataGridRow">
              <Style.Triggers>
                <MultiDataTrigger>
                  <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="False"/>
                    <Condition Binding="{Binding Grp}" Value="-1"/>
                  </MultiDataTrigger.Conditions>
                  <Setter Property="Background" Value="#444"/>
                </MultiDataTrigger>
                <MultiDataTrigger>
                  <MultiDataTrigger.Conditions>
                    <Condition Binding="{Binding RelativeSource={RelativeSource Self}, Path=IsSelected}" Value="True"/>
                    <Condition Binding="{Binding Grp}" Value="-1"/>
                  </MultiDataTrigger.Conditions>
                  <Setter Property="Background" Value="#FF5599CC"/>
                </MultiDataTrigger>
              </Style.Triggers>
            </Style>
          </DataGrid.RowStyle>
        </DataGrid>
        <GridSplitter x:Name="gridSplitter" HorizontalAlignment="Stretch" Margin="0,3,0,0" Grid.Row="2" VerticalAlignment="Top" TabIndex="1000" Height="8"/>
        <DataGrid x:Name="dgVtxIdxGrp" Margin="0,14,0,0" AutoGenerateColumns="False" CanUserReorderColumns="False" CanUserResizeColumns="False" CanUserSortColumns="False" GridLinesVisibility="Horizontal" ItemsSource="{Binding VIData}" CanUserAddRows="False" CanUserDeleteRows="False" CanUserResizeRows="False" HeadersVisibility="Column" IsEnabled="False" TabIndex="4" HorizontalContentAlignment="Stretch" Grid.Row="2" ContextMenuOpening="dgVtxIdxGrp_ContextMenuOpening">
          <DataGrid.Resources>
            <ResourceDictionary>
              <Style TargetType="{x:Type DataGridColumnHeader}" BasedOn="{StaticResource DGColumnHeaderStyle}"/>
              <Style TargetType="{x:Type CheckBox}" BasedOn="{StaticResource CellCheckBoxStyle}"/>
              <Style TargetType="{x:Type DataGridCell}" BasedOn="{StaticResource DGCellStyle}"/>
              <Style TargetType="{x:Type ComboBox}" BasedOn="{StaticResource ObjToolCellComboBoxStyle}"/>
            </ResourceDictionary>
          </DataGrid.Resources>
          <DataGrid.Columns>
            <DataGridTextColumn x:Name="dgcIndex" Binding="{Binding Index}" Header="ID" IsReadOnly="True" Width="30" MinWidth="30"/>
            <DataGridTextColumn x:Name="dgcGrpVtxCount" Binding="{Binding VtxCount}" Header="頂点数" IsReadOnly="True" Width="55" CellStyle="{StaticResource DGCellTextRight}" MinWidth="55"/>
            <DataGridTextColumn x:Name="dgcGrpIdxCount" Binding="{Binding IdxCount}" Header="Idx数" IsReadOnly="True" Width="55" CellStyle="{StaticResource DGCellTextRight}" MinWidth="55"/>
            <DataGridTextColumn x:Name="dgcObj" Binding="{Binding ObjName}" Header="オブジェクト名" IsReadOnly="True" Width="Auto" MinWidth="150" CellStyle="{StaticResource DGCellTextLeft}"/>
            <DataGridTextColumn x:Name="dgcUse" Binding="{Binding Use, UpdateSourceTrigger=PropertyChanged}" Header="Use" IsReadOnly="True" Width="38"  MinWidth="38"/>
            <!--<DataGridTextColumn x:Name="dgcGrpDecl" Binding="{Binding Decl}" Header="Decl" IsReadOnly="True" Width="38"  MinWidth="38"/>-->
            <DataGridTextColumn x:Name="dgcDatasize" Binding="{Binding Datasize}" Header="Size" IsReadOnly="True" Width="45" MinWidth="45"/>
            <DataGridTemplateColumn x:Name="dgcPosition" Header="Pos" IsReadOnly="True" Width="38" MinWidth="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding Position, UpdateSourceTrigger=PropertyChanged}" IsHitTestVisible="False"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="dgcPositionType" Binding="{Binding PositionType}" Header="Type" IsReadOnly="True" Width="60" MinWidth="60"/>
            <DataGridTemplateColumn x:Name="dgcNormal" Header="Nrm" IsReadOnly="True" Width="38" MinWidth="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding Normal, UpdateSourceTrigger=PropertyChanged}" IsHitTestVisible="{Binding IsEditable}" Click="CheckBox_Click"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="dgcNormalType" Binding="{Binding NormalType}" Header="Type" IsReadOnly="True" Width="60" MinWidth="60"/>
            <DataGridTemplateColumn x:Name="dgcBWeights" Header="Wgt" IsReadOnly="True" Width="38" MinWidth="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding BWeights, UpdateSourceTrigger=PropertyChanged}" IsHitTestVisible="{Binding IsEditable}" Click="CheckBox_Click"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="dgcBWeightsType" Binding="{Binding BWeightsType}" Header="Type" IsReadOnly="True" Width="60" MinWidth="60"/>
            <DataGridTemplateColumn x:Name="dgcBIndices" Header="Bld" IsReadOnly="True" Width="38" MinWidth="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding BIndices, UpdateSourceTrigger=PropertyChanged}" IsHitTestVisible="{Binding IsEditable}" Click="CheckBox_Click"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="dgcBIndicesType" Binding="{Binding BIndicesType}" Header="Type" IsReadOnly="True" Width="60" MinWidth="60"/>
            <DataGridTemplateColumn x:Name="dgcTangent" Header="Tan" IsReadOnly="True" Width="38" MinWidth="38">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <CheckBox IsChecked="{Binding Tangent, UpdateSourceTrigger=PropertyChanged}" IsHitTestVisible="{Binding IsEditable}" Click="CheckBox_Click"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <DataGridTextColumn x:Name="dgcTangentType" Binding="{Binding TangentType}" Header="Type" IsReadOnly="True" Width="60" MinWidth="60"/>
            <DataGridTemplateColumn x:Name="dgcUVCount" Header="UV数" IsReadOnly="True" Width="50" MinWidth="50">
              <DataGridTemplateColumn.CellTemplate>
                <DataTemplate>
                  <ComboBox x:Name="cmbUVCount" SelectedItem="{Binding UVCount,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding DataContext.UVCounts, RelativeSource={RelativeSource AncestorType=Window}}" IsEditable="False" IsHitTestVisible="{Binding IsEditable}"/>
                </DataTemplate>
              </DataGridTemplateColumn.CellTemplate>
            </DataGridTemplateColumn>
            <!--<DataGridTextColumn x:Name="dgcUVCount" Binding="{Binding UVCount}" Header="UV数" IsReadOnly="True" Width="50" MinWidth="50"/>-->
            <DataGridTextColumn Width="*" IsReadOnly="True" MinWidth="0"></DataGridTextColumn>
          </DataGrid.Columns>
        </DataGrid>
      </Grid>
      <custom:PathTrimTextBlock x:Name="textStatus" Margin="5" Path="ファイルを開いて下さい" VerticalAlignment="Bottom"/>
    </Grid>
  </Border>
</Window>