<UserControl x:Class="ConfigFileManager.Views.ConfigFileManager"
             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:ConfigFileManager.Views"
             mc:Ignorable="d" 
             xmlns:contorls="clr-namespace:ConfigFileManager.Controls"
             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>
                                        <contorls:ConfigFilePlot DeviceInfo="{Binding}" IsUpdate="{Binding ConfigUpdating}"
                                                                 CheckRecipeCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ConfigFileManager}, Path=DataContext.CheckRecipeCommand}"
                                                                 CheckConfigCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ConfigFileManager}, Path=DataContext.CheckConfigCommand}"
                                                                 MigrateCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ConfigFileManager}, Path=DataContext.MigrateCommand}"
                                                                 UpdateCommand="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=local:ConfigFileManager}, Path=DataContext.UpdateCommand}"/>
                                    </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>
