<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:bpa="clr-namespace:BPA.UIControl">

    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="pack://application:,,,/BPA.UIControl;component/Themes/Button.xaml" />
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="RubyerDialogContainer" TargetType="bpa:DialogContainer">
        <Setter Property="Background" Value="{DynamicResource FloatBackground}" />
        <Setter Property="MaskBackground" Value="{DynamicResource DialogBackground}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="BorderBrush" Value="Transparent" />
        <Setter Property="CornerRadius" Value="{DynamicResource AllContainerCornerRadius}" />
        <Setter Property="Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="IsTabStop" Value="False" />
        <Setter Property="Margin" Value="0" />
        <Setter Property="Padding" Value="10" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="IsEscKeyToClose" Value="False" />
        <Setter Property="IsShowCloseButton" Value="True" />
        <Setter Property="IsShow" Value="False" />
        <Setter Property="IsClosed" Value="True" />
        <Setter Property="bpa:HeaderHelper.FontSize" Value="{Binding FontSize, RelativeSource={RelativeSource Self}}" />
        <Setter Property="bpa:HeaderHelper.FontWeight" Value="Normal" />
        <Setter Property="bpa:HeaderHelper.Background" Value="{Binding Background, RelativeSource={RelativeSource Self}}" />
        <Setter Property="bpa:HeaderHelper.Foreground" Value="{DynamicResource DefaultForeground}" />
        <Setter Property="bpa:HeaderHelper.HorizontalAlignment" Value="Left" />
        <Setter Property="bpa:HeaderHelper.VerticalAlignment" Value="Center" />
        <Setter Property="bpa:HeaderHelper.Margin" Value="0" />
        <Setter Property="bpa:HeaderHelper.Padding" Value="10 5" />
        <Setter Property="bpa:HeaderHelper.CornerRadius" Value="{DynamicResource TopContainerCornerRadius}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="bpa:DialogContainer">
                    <Grid>
                        <ContentPresenter x:Name="PART_ContentPresenter"
                                          Panel.ZIndex="1"
                                          Focusable="False"
                                          RecognizesAccessKey="True"
                                          SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />

                        <Grid x:Name="cardRoot" Panel.ZIndex="100">
                            <bpa:Transition x:Name="Path_Transition" IsShow="{TemplateBinding IsShow}">
                                <Border x:Name="PART_BackgroundBorder" Background="{TemplateBinding MaskBackground}" />
                            </bpa:Transition>

                            <bpa:Transition InitialScale="0.5"
                                            IsShow="{TemplateBinding IsShow}"
                                            Type="Zoom">
                                <Border x:Name="PART_CardBorder"
                                        Margin="5"
                                        HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                        VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                        Background="{TemplateBinding Background}"
                                        BorderBrush="{TemplateBinding BorderBrush}"
                                        BorderThickness="{TemplateBinding BorderThickness}"
                                        CornerRadius="{TemplateBinding CornerRadius}"
                                        Effect="{DynamicResource AllDirectionEffect3}">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="Auto" />
                                            <RowDefinition Height="*" />
                                        </Grid.RowDefinitions>
                                        <Border x:Name="titleBar"
                                                Background="{Binding Path=(bpa:HeaderHelper.Background), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                CornerRadius="{Binding Path=(bpa:HeaderHelper.CornerRadius), RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                            <DockPanel Margin="{Binding Path=(bpa:HeaderHelper.Margin), RelativeSource={RelativeSource Mode=TemplatedParent}}">
                                                <Button x:Name="PART_CloseButton"
                                                        Style="{StaticResource TextButton}"
                                                        Height="Auto"
                                                        Padding="5"
                                                        bpa:ControlHelper.CornerRadius="{TemplateBinding CornerRadius}"
                                                        DockPanel.Dock="Right"
                                                        Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                        Visibility="{TemplateBinding IsShowCloseButton, Converter={StaticResource BooleanToVisibleConverter}}">
                                                    <bpa:Icon Type="CloseLine" />
                                                </Button>

                                                <TextBlock Margin="{Binding Path=(bpa:HeaderHelper.Padding), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           HorizontalAlignment="{Binding Path=(bpa:HeaderHelper.HorizontalAlignment), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           VerticalAlignment="{Binding Path=(bpa:HeaderHelper.VerticalAlignment), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           FontFamily="{Binding Path=(bpa:HeaderHelper.FontFamily), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           FontSize="{Binding Path=(bpa:HeaderHelper.FontSize), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           FontWeight="{Binding Path=(bpa:HeaderHelper.FontWeight), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           Foreground="{Binding Path=(bpa:HeaderHelper.Foreground), RelativeSource={RelativeSource Mode=TemplatedParent}}"
                                                           Text="{TemplateBinding Title}" />
                                            </DockPanel>
                                        </Border>

                                        <Border x:Name="contentBorder" Grid.Row="1">
                                            <ContentPresenter x:Name="dialogContent"
                                                              Margin="{TemplateBinding Padding}"
                                                              Content="{TemplateBinding DialogContent}"
                                                              Focusable="False"
                                                              SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                        </Border>
                                    </Grid>
                                </Border>
                            </bpa:Transition>
                        </Grid>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="Title" Value="{x:Null}" />
                                <Condition Property="IsShowCloseButton" Value="False" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="titleBar" Property="Visibility" Value="Collapsed" />
                            <Setter TargetName="contentBorder" Property="CornerRadius" Value="{DynamicResource AllContainerCornerRadius}" />
                        </MultiTrigger>
                        <MultiTrigger>
                            <MultiTrigger.Conditions>
                                <Condition Property="IsShow" Value="False" />
                                <Condition Property="IsClosed" Value="True" />
                            </MultiTrigger.Conditions>
                            <Setter TargetName="cardRoot" Property="Panel.ZIndex" Value="0" />
                            <Setter TargetName="cardRoot" Property="Visibility" Value="Collapsed" />
                        </MultiTrigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>