<UserControl x:Class="ProximaAnalizer.Views.Dialog.TraceDataList"
             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:local="clr-namespace:ProximaAnalizer.Views.Dialog"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
    </UserControl.Resources>
    <Grid Background="{StaticResource BackgroundColor}">
        <DataGrid Margin="4" Grid.Row="2" ItemsSource="{Binding DynamicDisplay}"
                  IsReadOnly="True"
                  CanUserAddRows="False"
                  CanUserDeleteRows="False"
                  CanUserSortColumns="False"
                  AutoGenerateColumns="False"
                  HorizontalScrollBarVisibility="Auto"
                  VerticalAlignment="Center"
                  HorizontalAlignment="Center"
                  BorderBrush="{StaticResource DarkBorderColor}"
                  HorizontalGridLinesBrush="{StaticResource DarkBorderColor}"
                  VerticalGridLinesBrush="{StaticResource DarkBorderColor}"
                  Background="Transparent"
                  TextElement.FontSize="14">
            <DataGrid.Columns>
                <DataGridTemplateColumn Header="Time">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <TextBlock Margin="8,4" Text="{Binding Value.Time, StringFormat=yyyy-MM-dd HH:mm:ss}"/>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn>
                    <DataGridTemplateColumn.Header>
                        <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:TraceDataList}, Path=DataContext.Headers}">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <Grid Width="200" >
                                        <TextBlock Text="{Binding}" HorizontalAlignment="Center" ToolTip="{Binding}"/>
                                    </Grid>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal"/>
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </ItemsControl>
                    </DataGridTemplateColumn.Header>
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ItemsControl ItemsSource="{Binding Value.Data}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid Width="200">
                                            <TextBlock Text="{Binding Value}"  HorizontalAlignment="Center"/>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Horizontal"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

                <DataGridTemplateColumn Header="Alarm" Width="*">
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <ItemsControl ItemsSource="{Binding Value.Alarm}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <Grid>
                                            <TextBlock Text="{Binding}" HorizontalAlignment="Left"></TextBlock>
                                        </Grid>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <StackPanel Orientation="Vertical"/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
            </DataGrid.Columns>
        </DataGrid>
        <Button VerticalAlignment="Top" HorizontalAlignment="Right" Margin="4,4" Width="80" Panel.ZIndex="1" Style="{StaticResource FunctionButton}" Command="{Binding ExportCommand}">导出csv</Button>
    </Grid>
</UserControl>
