<UserControl x:Class="DashBoard.View.DashBoardMain"
             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:DashBoard.View"
             xmlns:controls="clr-namespace:DashBoard.Controls"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary >
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
            </ResourceDictionary.MergedDictionaries>
            <local:DeviceContert x:Key="DeviceConverter"/>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <ScrollViewer>
            <ItemsControl ItemsSource="{Binding DeviceData}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <Expander Header="{Binding Key}" IsExpanded="True">
                            <ItemsControl ItemsSource="{Binding Value}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <controls:DeviceInfoPlot DeviceData="{Binding}"
                                                                 AlarmCommand="{Binding RelativeSource={RelativeSource AncestorType=local:DashBoardMain, Mode=FindAncestor}, Path=DataContext.WarningCommand}">
                                            <controls:DeviceInfoPlot.DeviceInfo>
                                                <MultiBinding Converter="{StaticResource DeviceConverter}">
                                                    <Binding RelativeSource="{RelativeSource AncestorType=local:DashBoardMain, Mode=FindAncestor}" Path="DataContext.Devices"/>
                                                    <Binding Path="DeviceId"/>
                                                </MultiBinding>
                                            </controls:DeviceInfoPlot.DeviceInfo>
                                        </controls:DeviceInfoPlot>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </Expander>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>