<UserControl x:Class="HistoryView.Controls.WarningItemCollection"
             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:HistoryView.Controls"
             mc:Ignorable="d" 
             x:Name="This"
             d:DesignHeight="450" d:DesignWidth="800">
    <Grid>
        <Expander ExpandDirection="Down" Style="{StaticResource ExpanderStyle1}">
            <Expander.Header>
                <Border  Background="#e4e4e4" Margin="4,0" CornerRadius="4">
                    <Grid Margin="16,0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="auto"/>
                        </Grid.ColumnDefinitions>
                        <local:WarningItem Alarm="{Binding ElementName=This, Path=Latest}" VerticalAlignment="Center" TextElement.FontSize="14" />
                        <Button Grid.Column="1" Style="{StaticResource FunctionButton}" MinWidth="60" VerticalAlignment="Center" Command="{Binding ElementName=This, Path=Clear}" CommandParameter="{Binding ElementName=This, Path=Latest}" Content="{DynamicResource Clear}"/>
                    </Grid>
                </Border>
            </Expander.Header>
            <ItemsControl ItemsSource="{Binding ElementName=This, Path=Alarms}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Border Background="{StaticResource BackgroundColor}">
                            <local:WarningItem Alarm="{Binding Value}" Margin="64,0,0,0" TextElement.FontSize="13" />
                        </Border>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel VerticalAlignment="Top"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </Expander>
    </Grid>
</UserControl>
