<UserControl x:Class="Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Hosting.SectionView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Converters="clr-namespace:Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Converters"
    xmlns:Hosting="clr-namespace:Microsoft.Practices.EnterpriseLibrary.Configuration.Design.Hosting"
    mc:Ignorable="d"
    Hosting:ConfigurationResources.MergedDictionaries="ExpanderDictionary;ViewModelDataTemplates;ExtendedDictionary">
    <UserControl.Resources>
        <Converters:InverseBooleanToCollapsedConverter x:Key="InverseBooleanToCollapsedConverter"/>

        <Style x:Key="BackgroundSectionStyle" TargetType="{x:Type TextBlock}">
            <Setter Property="HorizontalAlignment" Value="Left" />
            <Setter Property="VerticalAlignment" Value="Top" />
            <Setter Property="Opacity" Value="0.35" />
            <Setter Property="FontSize" Value="16" />
            <Setter Property="FontWeight" Value="ExtraBold" />
            <Setter Value="False" Property="IsHitTestVisible" />
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"  />
            <Setter Property="TextAlignment" Value="Right"/>
            <Setter Property="FontStretch" Value="Expanded"/>
            <Setter Property="TextWrapping" Value="NoWrap"/>
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Margin" Value="0,5"/>
            <Setter Property="Height" Value="0" />
            <Setter Property="Width" Value="0" />
            <Style.Triggers>
                <Trigger Property="Visibility" Value="Visible">
                    <Setter Property="Width" Value="Auto" />
                    <Setter Property="Height" Value="Auto" />
                    <Setter Property="LayoutTransform">
                        <Setter.Value>
                            <TransformGroup>
                                <ScaleTransform/>
                                <SkewTransform/>
                                <RotateTransform Angle="-90"/>
                                <TranslateTransform/>
                            </TransformGroup>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <ScrollViewer x:Name="scrollViewer" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
            <Grid x:Name="Environments" Grid.Row="0" DataContext="{Binding Environments}" Visibility="{Binding IsEmpty, Converter={StaticResource InverseBooleanToCollapsedConverter}}" >
                <TextBlock x:Name="TextBlock" 
        				Style="{DynamicResource BackgroundSectionStyle}" HorizontalAlignment="Left" VerticalAlignment="Stretch">						
						Environments
                </TextBlock>

                <ItemsControl 
                        Visibility="{Binding Visibility, ElementName=Environments}"
                        Focusable="False" ItemsSource="{Binding}" Margin="20,0,0,0"/>
            </Grid>
        </ScrollViewer>
        <GridSplitter Grid.Row="1" ResizeDirection="Rows" Height="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Visibility="{Binding Environments.IsEmpty, Converter={StaticResource InverseBooleanToCollapsedConverter}}" Background="{DynamicResource {x:Static SystemColors.ControlLightBrushKey}}" Margin="0,1" />
        <ScrollViewer Grid.Row="2" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" >
            <Grid Grid.Row="2" DataContext="{Binding CurrentConfigurationSource}">
                <TextBlock HorizontalAlignment="Center" Margin="40,0,0,0" FontSize="24" Foreground="#FFD8E2F4" Padding="3" VerticalAlignment="Center" FontWeight="SemiBold" TextAlignment="Center" Visibility="{Binding HasItems, Converter={StaticResource InverseBooleanToCollapsedConverter}, ElementName=itemsControl, Mode=Default}">Get started by adding a block or selecting a wizard from the menu.</TextBlock>
                <TextBlock Style="{DynamicResource BackgroundSectionStyle}"><Run Text="Blocks Configuration"/></TextBlock>
                <ItemsControl x:Name="itemsControl" Focusable="False" ItemsSource="{Binding Sections}" Margin="20,0,0,0" d:LayoutOverrides="Height"/>
            </Grid>
        </ScrollViewer>
    </Grid>
</UserControl>
