<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:noesis="clr-namespace:NoesisGUIExtensions;assembly=Noesis.GUI.Extensions"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
    xmlns:sys="clr-namespace:System;assembly=mscorlib">

    <ControlTemplate x:Key="Template.Modal">
        <!-- Defines the container of the modal -->
        <Border
            x:Name="Root"
            Background="{TemplateBinding Background}"
            BorderBrush="{TemplateBinding BorderBrush}"
            Effect="{TemplateBinding Effect}"
            BorderThickness="2"
            HorizontalAlignment="Stretch"
            VerticalAlignment="Stretch">

            <!-- This displays the internal border and wraps the rest of the content -->
            <Border
                x:Name="Container"
                BorderBrush="{DynamicResource Color.BorderInModal}"
                BorderThickness="2" >

                <Grid x:Name="Wrapper">

                    <!-- This Grid displays the internal decorative border -->
                    <Grid x:Name="Decor" Opacity="0.15">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="24"/>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="24"/>
                        </Grid.ColumnDefinitions>

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

                        <Rectangle Grid.Column="0" Grid.Row="0" Fill="{DynamicResource Decor01.TL}"/>
                        <Rectangle Grid.Column="1" Grid.Row="0" Fill="{DynamicResource Decor01.T}"/>
                        <Rectangle Grid.Column="2" Grid.Row="0" Fill="{DynamicResource Decor01.TR}"/>

                        <Rectangle Grid.Column="0" Grid.Row="1" Fill="{DynamicResource Decor01.ML}"/>
                        <Rectangle Grid.Column="1" Grid.Row="1" Fill="{DynamicResource Decor01.M}"/>
                        <Rectangle Grid.Column="2" Grid.Row="1" Fill="{DynamicResource Decor01.MR}"/>

                        <Rectangle Grid.Column="0" Grid.Row="2" Fill="{DynamicResource Decor01.BL}"/>
                        <Rectangle Grid.Column="1" Grid.Row="2" Fill="{DynamicResource Decor01.B}"/>
                        <Rectangle Grid.Column="2" Grid.Row="2" Fill="{DynamicResource Decor01.BR}"/>
                    </Grid>

                    <Border
                        x:Name="Content"
                        Padding="2"
                        BorderThickness="0">

                        <!-- The ContentPresenter renders content inside of the item -->
                        <ContentPresenter
                            HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                            VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                    </Border>
                </Grid>
            </Border>
        </Border>
    </ControlTemplate>

    <Style x:Key="Style.Modal" TargetType="{x:Type UserControl}">
        <Setter Property="Background" Value="{DynamicResource Color.BackgroundModal}"/>
        <Setter Property="BorderBrush" Value="{DynamicResource Color.BorderOutModal}"/>
        <Setter Property="Effect" Value="{DynamicResource Shadow.Modal}"/>
        <Setter Property="Template" Value="{StaticResource Template.Modal}"/>
    </Style>
</ResourceDictionary>
