Themes/MaterialDesignTheme.DialogHost.xaml

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:wpf="clr-namespace:MaterialDesignThemes.Wpf"
                    xmlns:converters="clr-namespace:MaterialDesignThemes.Wpf.Converters"
                    xmlns:convertersInternal="clr-namespace:MaterialDesignThemes.Wpf.Converters.Internal">
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Font.xaml" />
  </ResourceDictionary.MergedDictionaries>
 
  <Style x:Key="MaterialDesignDialogHostPopup" TargetType="{x:Type wpf:PopupEx}">
    <Setter Property="AllowsTransparency" Value="True" />
    <Setter Property="Placement" Value="Center" />
    <Setter Property="PopupAnimation" Value="None" />
    <Setter Property="StaysOpen" Value="True" />
  </Style>
 
  <Style TargetType="{x:Type wpf:DialogHost}">
    <Setter Property="DialogMargin" Value="35" />
    <Setter Property="DialogTheme" Value="Inherit" />
    <Setter Property="FocusVisualStyle" Value="{x:Null}" />
    <Setter Property="PopupStyle" Value="{StaticResource MaterialDesignDialogHostPopup}" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="wpf:DialogHost">
          <Grid x:Name="DialogHostRoot" Focusable="False">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="PopupStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="Closed" To="Open">
                    <Storyboard>
                      <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="IsOpen">
                        <DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
                      </BooleanAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentCoverBorder" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.56">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_PopupContentElement" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleX">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleY">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Open" To="Closed">
                    <Storyboard>
                      <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="IsOpen">
                        <DiscreteBooleanKeyFrame KeyTime="0:0:0.3" Value="False" />
                      </BooleanAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentCoverBorder" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0.56" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_PopupContentElement" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.18" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleX">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.18" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.5">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleY">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.18" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.5">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Open">
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup"
                                                    Storyboard.TargetProperty="IsOpen"
                                                    Duration="0">
                      <DiscreteBooleanKeyFrame KeyTime="0" Value="True" />
                    </BooleanAnimationUsingKeyFrames>
                    <DoubleAnimation Storyboard.TargetName="ContentCoverBorder"
                                     Storyboard.TargetProperty="Opacity"
                                     To=".56"
                                     Duration="0" />
                    <DoubleAnimation Storyboard.TargetName="PART_PopupContentElement"
                                     Storyboard.TargetProperty="Opacity"
                                     To="1"
                                     Duration="0" />
                    <DoubleAnimation Storyboard.TargetName="CardScaleTransform"
                                     Storyboard.TargetProperty="ScaleX"
                                     To="1"
                                     Duration="0" />
                    <DoubleAnimation Storyboard.TargetName="CardScaleTransform"
                                     Storyboard.TargetProperty="ScaleY"
                                     To="1"
                                     Duration="0" />
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Closed">
                  <Storyboard>
                    <BooleanAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="IsOpen">
                      <DiscreteBooleanKeyFrame KeyTime="0" Value="False" />
                    </BooleanAnimationUsingKeyFrames>
                    <DoubleAnimation Storyboard.TargetName="ContentCoverBorder"
                                     Storyboard.TargetProperty="Opacity"
                                     To="0"
                                     Duration="0" />
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <wpf:PopupEx x:Name="PART_Popup"
                         wpf:ThemeAssist.Theme="{TemplateBinding DialogTheme}"
                         Placement="{TemplateBinding Placement}"
                         PlacementTarget="{Binding ElementName=DialogHostRoot, Mode=OneWay}"
                         Style="{TemplateBinding PopupStyle}">
              <Grid>
                <Border Background="Transparent" IsHitTestVisible="{TemplateBinding CloseOnClickAway}">
                  <Border.InputBindings>
                    <MouseBinding Command="{x:Static wpf:DialogHost.CloseDialogCommand}"
                                  CommandParameter="{TemplateBinding CloseOnClickAwayParameter}"
                                  MouseAction="LeftClick" />
                  </Border.InputBindings>
                </Border>
                <wpf:Card x:Name="PART_PopupContentElement"
                          Margin="{TemplateBinding DialogMargin}"
                          wpf:ElevationAssist.Elevation="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation)}"
                          Content="{TemplateBinding DialogContent}"
                          ContentStringFormat="{TemplateBinding DialogContentStringFormat}"
                          ContentTemplate="{TemplateBinding DialogContentTemplate}"
                          ContentTemplateSelector="{TemplateBinding DialogContentTemplateSelector}"
                          FocusManager.IsFocusScope="False"
                          Focusable="True"
                          Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
                          IsHitTestVisible="True"
                          IsTabStop="False"
                          Opacity="0"
                          RenderTransformOrigin=".5,.5"
                          Tag="{TemplateBinding DialogBackground}"
                          TextElement.Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
                          UniformCornerRadius="{TemplateBinding DialogContentUniformCornerRadius}">
                  <wpf:Card.Style>
                    <Style TargetType="wpf:Card" BasedOn="{StaticResource {x:Type wpf:Card}}">
                      <Setter Property="Background" Value="{Binding Tag, RelativeSource={RelativeSource Self}}" />
                      <Style.Triggers>
                        <Trigger Property="Tag" Value="{x:Null}">
                          <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Background}" />
                        </Trigger>
                      </Style.Triggers>
                    </Style>
                  </wpf:Card.Style>
                  <wpf:Card.RenderTransform>
                    <TransformGroup>
                      <ScaleTransform x:Name="CardScaleTransform" ScaleX="0" ScaleY="0" />
                    </TransformGroup>
                  </wpf:Card.RenderTransform>
                </wpf:Card>
              </Grid>
            </wpf:PopupEx>
            <AdornerDecorator>
              <ContentPresenter x:Name="ContentPresenter"
                                Content="{TemplateBinding ContentControl.Content}"
                                ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
                                ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
                                Opacity="1">
                <ContentPresenter.Effect>
                  <MultiBinding Converter="{x:Static convertersInternal:DialogBackgroundBlurConverter.Instance}">
                    <Binding Path="IsOpen" RelativeSource="{RelativeSource TemplatedParent}" />
                    <Binding Path="ApplyBlurBackground" RelativeSource="{RelativeSource TemplatedParent}" />
                    <Binding Path="BlurRadius" RelativeSource="{RelativeSource TemplatedParent}" />
                  </MultiBinding>
                </ContentPresenter.Effect>
              </ContentPresenter>
            </AdornerDecorator>
            <Grid x:Name="PART_ContentCoverGrid"
                  Background="Transparent"
                  Focusable="False"
                  IsHitTestVisible="False"
                  Visibility="{Binding ElementName=ContentCoverBorder, Path=Visibility}">
              <Grid.OpacityMask>
                <VisualBrush>
                  <VisualBrush.Visual>
                    <MultiBinding Converter="{x:Static converters:FirstNonNullConverter.Instance}">
                      <Binding ElementName="ContentCoverBorder" />
                      <Binding Source="{x:Static DependencyProperty.UnsetValue}" />
                    </MultiBinding>
                  </VisualBrush.Visual>
                </VisualBrush>
              </Grid.OpacityMask>
              <Border x:Name="ContentCoverBorder"
                      Background="{Binding OverlayBackground, RelativeSource={RelativeSource TemplatedParent}}"
                      CornerRadius="{TemplateBinding CornerRadius}"
                      IsHitTestVisible="False"
                      Opacity="0">
                <Border.Style>
                  <Style TargetType="Border">
                    <Style.Triggers>
                      <Trigger Property="Opacity" Value="0">
                        <Setter Property="Visibility" Value="Hidden" />
                      </Trigger>
                    </Style.Triggers>
                  </Style>
                </Border.Style>
              </Border>
            </Grid>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsOpen" Value="True">
              <Setter TargetName="PART_ContentCoverGrid" Property="IsHitTestVisible" Value="True" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="wpf:ElevationAssist.Elevation" Value="Dp24" />
  </Style>
 
  <Style x:Key="MaterialDesignEmbeddedDialogHost" TargetType="{x:Type wpf:DialogHost}">
    <Setter Property="DialogMargin" Value="35" />
    <Setter Property="HorizontalContentAlignment" Value="Center" />
    <Setter Property="Placement" Value="Center" />
    <Setter Property="Template">
      <Setter.Value>
        <ControlTemplate TargetType="wpf:DialogHost">
          <Grid x:Name="DialogHostRoot" Focusable="False">
            <VisualStateManager.VisualStateGroups>
              <VisualStateGroup x:Name="PopupStates">
                <VisualStateGroup.Transitions>
                  <VisualTransition From="Closed" To="Open">
                    <Storyboard>
                      <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="Visibility">
                        <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                      </ObjectAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentCoverBorder" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.56">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_PopupContentElement" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleX">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleY">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="1">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                  <VisualTransition From="Open" To="Closed">
                    <Storyboard>
                      <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup" Storyboard.TargetProperty="Visibility">
                        <DiscreteObjectKeyFrame KeyTime="0:0:0.3" Value="{x:Static Visibility.Collapsed}" />
                      </ObjectAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="ContentCoverBorder" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="0.56" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="PART_PopupContentElement" Storyboard.TargetProperty="Opacity">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.18" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleX">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.18" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.5">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                      <DoubleAnimationUsingKeyFrames Storyboard.TargetName="CardScaleTransform" Storyboard.TargetProperty="ScaleY">
                        <EasingDoubleKeyFrame KeyTime="0" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.18" Value="1" />
                        <EasingDoubleKeyFrame KeyTime="0:0:0.3" Value="0.5">
                          <EasingDoubleKeyFrame.EasingFunction>
                            <SineEase EasingMode="EaseInOut" />
                          </EasingDoubleKeyFrame.EasingFunction>
                        </EasingDoubleKeyFrame>
                      </DoubleAnimationUsingKeyFrames>
                    </Storyboard>
                  </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="Open">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup"
                                                   Storyboard.TargetProperty="Visibility"
                                                   Duration="0">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}" />
                    </ObjectAnimationUsingKeyFrames>
                    <DoubleAnimation Storyboard.TargetName="ContentCoverBorder"
                                     Storyboard.TargetProperty="Opacity"
                                     To=".56"
                                     Duration="0" />
                    <DoubleAnimation Storyboard.TargetName="PART_PopupContentElement"
                                     Storyboard.TargetProperty="Opacity"
                                     To="1"
                                     Duration="0" />
                    <DoubleAnimation Storyboard.TargetName="CardScaleTransform"
                                     Storyboard.TargetProperty="ScaleX"
                                     To="1"
                                     Duration="0" />
                    <DoubleAnimation Storyboard.TargetName="CardScaleTransform"
                                     Storyboard.TargetProperty="ScaleY"
                                     To="1"
                                     Duration="0" />
                  </Storyboard>
                </VisualState>
                <VisualState x:Name="Closed">
                  <Storyboard>
                    <ObjectAnimationUsingKeyFrames Storyboard.TargetName="PART_Popup"
                                                   Storyboard.TargetProperty="Visibility"
                                                   Duration="0">
                      <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Collapsed}" />
                    </ObjectAnimationUsingKeyFrames>
                    <DoubleAnimation Storyboard.TargetName="ContentCoverBorder"
                                     Storyboard.TargetProperty="Opacity"
                                     To="0"
                                     Duration="0" />
                  </Storyboard>
                </VisualState>
              </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
            <ContentPresenter x:Name="ContentPresenter"
                              Content="{TemplateBinding ContentControl.Content}"
                              ContentStringFormat="{TemplateBinding ContentControl.ContentStringFormat}"
                              ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
                              Opacity="1">
              <ContentPresenter.Effect>
                <MultiBinding Converter="{x:Static convertersInternal:DialogBackgroundBlurConverter.Instance}">
                  <Binding Path="IsOpen" RelativeSource="{RelativeSource TemplatedParent}" />
                  <Binding Path="ApplyBlurBackground" RelativeSource="{RelativeSource TemplatedParent}" />
                  <Binding Path="BlurRadius" RelativeSource="{RelativeSource TemplatedParent}" />
                </MultiBinding>
              </ContentPresenter.Effect>
            </ContentPresenter>
 
            <Grid x:Name="PART_ContentCoverGrid"
                  Background="Transparent"
                  Focusable="False"
                  IsHitTestVisible="False"
                  Visibility="{Binding ElementName=ContentCoverBorder, Path=Visibility}">
              <Grid.OpacityMask>
                <VisualBrush>
                  <VisualBrush.Visual>
                    <MultiBinding Converter="{x:Static converters:FirstNonNullConverter.Instance}">
                      <Binding ElementName="ContentCoverBorder" />
                      <Binding Source="{x:Static DependencyProperty.UnsetValue}" />
                    </MultiBinding>
                  </VisualBrush.Visual>
                </VisualBrush>
              </Grid.OpacityMask>
              <Border x:Name="ContentCoverBorder"
                      Background="{Binding OverlayBackground, RelativeSource={RelativeSource TemplatedParent}}"
                      CornerRadius="{TemplateBinding CornerRadius}"
                      IsHitTestVisible="False"
                      Opacity="0">
                <Border.Style>
                  <Style TargetType="Border">
                    <Style.Triggers>
                      <Trigger Property="Opacity" Value="0">
                        <Setter Property="Visibility" Value="Hidden" />
                      </Trigger>
                    </Style.Triggers>
                  </Style>
                </Border.Style>
              </Border>
            </Grid>
 
            <Grid x:Name="PART_Popup"
                  HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                  wpf:ThemeAssist.Theme="{TemplateBinding DialogTheme}">
              <wpf:Card x:Name="PART_PopupContentElement"
                        Margin="{TemplateBinding DialogMargin}"
                        wpf:ElevationAssist.Elevation="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ElevationAssist.Elevation)}"
                        Content="{TemplateBinding DialogContent}"
                        ContentStringFormat="{TemplateBinding DialogContentStringFormat}"
                        ContentTemplate="{TemplateBinding DialogContentTemplate}"
                        ContentTemplateSelector="{TemplateBinding DialogContentTemplateSelector}"
                        FocusManager.IsFocusScope="False"
                        Focusable="True"
                        Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
                        IsTabStop="False"
                        Opacity="0"
                        RenderTransformOrigin=".5,.5"
                        Tag="{TemplateBinding DialogBackground}"
                        TextElement.Foreground="{DynamicResource MaterialDesign.Brush.Foreground}"
                        UniformCornerRadius="{TemplateBinding DialogContentUniformCornerRadius}">
                <wpf:Card.RenderTransform>
                  <TransformGroup>
                    <ScaleTransform x:Name="CardScaleTransform" ScaleX="0" ScaleY="0" />
                  </TransformGroup>
                </wpf:Card.RenderTransform>
                <wpf:Card.Style>
                  <Style TargetType="wpf:Card" BasedOn="{StaticResource {x:Type wpf:Card}}">
                    <Setter Property="Background" Value="{Binding Tag, RelativeSource={RelativeSource Self}}" />
                    <Style.Triggers>
                      <Trigger Property="Tag" Value="{x:Null}">
                        <Setter Property="Background" Value="{DynamicResource MaterialDesign.Brush.Background}" />
                      </Trigger>
                    </Style.Triggers>
                  </Style>
                </wpf:Card.Style>
              </wpf:Card>
            </Grid>
          </Grid>
          <ControlTemplate.Triggers>
            <Trigger Property="IsOpen" Value="True">
              <Setter TargetName="PART_ContentCoverGrid" Property="IsHitTestVisible" Value="True" />
            </Trigger>
          </ControlTemplate.Triggers>
        </ControlTemplate>
      </Setter.Value>
    </Setter>
    <Setter Property="VerticalContentAlignment" Value="Center" />
    <Setter Property="wpf:ElevationAssist.Elevation" Value="Dp24" />
    <Style.Triggers>
      <Trigger Property="Placement" Value="Center">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
      </Trigger>
      <Trigger Property="Placement" Value="Left">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
      </Trigger>
      <Trigger Property="Placement" Value="Top">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
      </Trigger>
      <Trigger Property="Placement" Value="Right">
        <Setter Property="HorizontalContentAlignment" Value="Right" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
      </Trigger>
      <Trigger Property="Placement" Value="Bottom">
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Bottom" />
      </Trigger>
      <Trigger Property="Placement" Value="Absolute">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
      </Trigger>
      <Trigger Property="Placement" Value="AbsolutePoint">
        <Setter Property="HorizontalContentAlignment" Value="Left" />
        <Setter Property="VerticalContentAlignment" Value="Top" />
      </Trigger>
    </Style.Triggers>
  </Style>
</ResourceDictionary>