<UserControl x:Class="Valg.EVA.Skanning.UserInterfaceElements.EmergencyMode.SelectMunicipalityView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:emergencyMode="clr-namespace:Valg.EVA.Skanning.UserInterfaceElements.EmergencyMode"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignInstance d:Type=emergencyMode:SelectMunicipalityViewModel}">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <TextBlock Grid.Row="0" Text="{Binding Title}" Style="{StaticResource TextBlockMediumHeader}"  Margin="0,0,0,20" />

        <ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Auto"  HorizontalScrollBarVisibility="Hidden">
            <ItemsControl ItemsSource="{Binding Counties}">
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Margin="0,0,0,10">
                            <ToggleButton Background="White" Foreground="{StaticResource ActiveElementBackgroundBrush}" IsChecked="{Binding IsExpanded}">
                                <ToggleButton.Template>
                                    <ControlTemplate>
                                        <Grid Cursor="Hand">
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="auto" />
                                                <ColumnDefinition Width="*" />
                                            </Grid.ColumnDefinitions>
                                            <TextBlock Grid.Column="0" Style="{StaticResource PlayArrowIcon}" Visibility="{Binding IsExpanded, Converter={StaticResource InvertedBooleanToVisibilityConverter}}" FontSize="12" VerticalAlignment="Center" />
                                            <TextBlock Grid.Column="0" Style="{StaticResource DownArrowIcon}" Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToVisibilityConverter}}" FontSize="12" VerticalAlignment="Center" />
                                            <StackPanel Orientation="Horizontal" Grid.Column="1">
                                                <TextBlock Text="{Binding Path=CurrentCounty.Name}" Style="{StaticResource TextBlockNormal}" Margin="5,0,0,0" VerticalAlignment="Center" TextDecorations="Underline" />
                                            </StackPanel>
                                        </Grid>
                                    </ControlTemplate>
                                </ToggleButton.Template>
                            </ToggleButton>
                            <ItemsControl ItemsSource="{Binding MunicipalitiesInCounty}" Visibility="{Binding IsExpanded, Converter={StaticResource BooleanToVisibilityConverter}}">
                                <ItemsControl.ItemTemplate>
                                    <DataTemplate>
                                        <CheckBox IsChecked="{Binding IsChecked}" Margin="20, 3, 0, 0" Command="{Binding Path=DataContext.CheckBoxIsCheckedCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type emergencyMode:SelectMunicipalityView} } }">
                                            <TextBlock Text="{Binding Name}" Style="{StaticResource TextBlockNormal}" />
                                        </CheckBox>
                                    </DataTemplate>
                                </ItemsControl.ItemTemplate>
                            </ItemsControl>
                        </StackPanel>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>
    </Grid>
</UserControl>
