<fw:NChildWindow x:Class="Com.FirmLib.UI.Manufacturer.WinProductType"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:fw="http://schemas.FWind/xaml"
             xmlns:uc="clr-namespace:Com.FirmLib.UI.Common"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:behaviors="clr-namespace:FWindSoft.Wpf.Behaviors;assembly=FWindSoft.Wpf"
             xmlns:dgx="urn:tom-englert.de/DataGridExtensions"
             mc:Ignorable="d" d:DesignHeight="300" d:DesignWidth="500" Title="[品牌名-产品名]型号" Height="{Binding Height,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=UIElement}}"
                 Width="{Binding ActualWidth,RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=ScrollContentPresenter}}">
    <fw:NChildWindow.Resources>
        <fw:BindingProxy x:Key="DATA" Data="{Binding}"></fw:BindingProxy>
        <Style x:Key="CenterAlignmentStyle" TargetType="TextBlock">
            <Setter Property="TextAlignment" Value="Center"/>
            <Setter Property="VerticalAlignment" Value="Center"/>
        </Style>
    </fw:NChildWindow.Resources>
    <fw:NChildWindow.AttachElement>
        <StackPanel HorizontalAlignment="Stretch" Orientation="Horizontal" VerticalAlignment="Center">
            <Button  Command="{Binding Data.Commands.SaveCommand,Source={StaticResource ResourceKey=DATA}}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  BorderThickness="0"  FontFamily="{DynamicResource ResourceKey={x:Static fw:FontsUtil.AwesomeKey}}">
                <Button.Content>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{fw:FontIcon Icon=Save}"  Width="30" FontSize="20"></TextBlock>
                        <TextBlock Text="保存" VerticalAlignment="Center" Margin="-5,0,0,0"></TextBlock>
                    </StackPanel>
                </Button.Content>
            </Button>
        </StackPanel>

    </fw:NChildWindow.AttachElement>

    <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Grid.Row="0" Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
            <Button Command="{Binding Commands.AddTypeCommand}" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.ButtonKey}}"  Height="23"  Margin="10" Content="添加型号"/>
        </StackPanel>
        <DataGrid Name="DataGrid" fw:DataGridDragCopyOptions.CanDragCopy="True" Grid.Row="1" Grid.Column="0"     AutoGenerateColumns="False" SelectionMode="Extended"  FrozenColumnCount="2" ItemsSource="{Binding TypeItems,UpdateSourceTrigger=PropertyChanged}"
                CanUserAddRows="False"
                CanUserDeleteRows="False"
                VerticalScrollBarVisibility="Auto"
                HorizontalScrollBarVisibility="Auto"
                SelectionUnit="FullRow"
                HeadersVisibility="Column" 
                CanUserSortColumns="True"   
                  dgx:DataGridFilter.IsAutoFilterEnabled="True"
                CellStyle="{StaticResource ResourceKey={x:Static uc:CommonStyles.DataGridCellKey}}"
                  SelectedItem="{Binding CurrentTypeItem,Mode=OneWay}"
                  
                  AlternationCount="2"
                >
          
            <DataGrid.RowStyle>
                <Style TargetType="DataGridRow">
                    <Setter Property="ContextMenu">
                        <Setter.Value>
                            <ContextMenu>
                                <MenuItem Header="删除" Command="{Binding Data.Commands.DeleteCommand,Source={StaticResource ResourceKey=DATA}}" CommandParameter="{Binding }"></MenuItem>
                            </ContextMenu>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="Height" Value="30"></Setter>
                    <Style.Triggers>
                        <Trigger Property="ItemsControl.AlternationIndex"
                                 Value="0">
                            <Setter Property="Background" Value="White" />
                        </Trigger>
                        <Trigger Property="ItemsControl.AlternationIndex"
                                 Value="1">
                            <Setter Property="Background" Value="#FFE6E3DD" />
                        </Trigger>
                    </Style.Triggers>
                </Style>
            </DataGrid.RowStyle>
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="操作"  Width="100" IsReadOnly="True" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <StackPanel Orientation="Horizontal">
                                <Button IsEnabled="False" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"   Content="管理型号常见问题"  HorizontalAlignment="Left"  Padding="5,0,5,0"/>
                                <Button IsEnabled="False" Style="{StaticResource ResourceKey={x:Static uc:CommonStyles.LinkButtonKey}}"   Content="查看新增的参数值"  HorizontalAlignment="Left"  Padding="5,0,5,0"/>
                            </StackPanel>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>

                </DataGridTemplateColumn>
                <!--<DataGridTextColumn Header="型号" fw:DataGridDragCopyOptions.CanColumnDragCopy="True" Width="100"   Binding="{Binding Path=TypeName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ElementStyle="{StaticResource CenterAlignmentStyle}">

                </DataGridTextColumn>-->
                <fw:TDataGridTextColumn Header="型号" CanPaste="True" fw:DataGridDragCopyOptions.CanColumnDragCopy="True" Width="100"   Binding="{Binding Path=TypeName,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"></fw:TDataGridTextColumn>
                <!--<i:Interaction.Behaviors>
                    <behaviors:GridCellSingleClickEditBehavior></behaviors:GridCellSingleClickEditBehavior>
                </i:Interaction.Behaviors>-->

            </DataGrid.Columns>
          
        </DataGrid>
    </Grid>
</fw:NChildWindow>

