<UserControl x:Class="DeviceManagement.Views.DeviceManager"
             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:DeviceManagement.Views"
             xmlns:controls="clr-namespace:DeviceManagement.Controls"
             xmlns:prism="http://prismlibrary.com/"
             prism:ViewModelLocator.AutoWireViewModel="True"
             mc:Ignorable="d" 
             d:DesignHeight="450" d:DesignWidth="800">
    <UserControl.Resources>
        <ResourceDictionary Source="/UICommon;component/Resources.xaml"/>
    </UserControl.Resources>
    <Grid>
        <ScrollViewer>
            <ItemsControl ItemsSource="{Binding Devices}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>

                        <Expander Margin="8" IsExpanded="True">
                            <Expander.Header>
                                <TextBlock Text="{Binding Key}" FontSize="13"></TextBlock>
                            </Expander.Header>

                            <ItemsControl ItemsSource="{Binding Value}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <controls:DevicePlot DeviceInfo="{Binding}" Margin="8"
                                        DetailCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DeviceManager}, Path=DataContext.CheckDetailCommand}"
                                        RemoteControlCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DeviceManager}, Path=DataContext.RemoteCommand}"
                                        SettingCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DeviceManager}, Path=DataContext.SettingCommand}"
                                        DeleteCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:DeviceManager}, Path=DataContext.DeleteCommand}"/>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                                <ItemsControl.ItemsPanel>
                                    <ItemsPanelTemplate>
                                        <WrapPanel/>
                                    </ItemsPanelTemplate>
                                </ItemsControl.ItemsPanel>
                            </ItemsControl>
                        </Expander>

                    </DataTemplate>
                </ItemsControl.ItemTemplate>

                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <StackPanel/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>
