Skip to content

Commit 84deec7

Browse files
committed
Added a style to control the Popup in the dialog host. I personally like this option better than simply adding an attached property because it gives greater control and is more discoverable.
1 parent a07f19f commit 84deec7

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,15 @@ public SnackbarMessageQueue SnackbarMessageQueue
411411
set { SetValue(SnackbarMessageQueueProperty, value); }
412412
}
413413

414+
public static readonly DependencyProperty PopupStyleProperty = DependencyProperty.Register(
415+
nameof(PopupStyle), typeof(Style), typeof(DialogHost), new PropertyMetadata(default(Style)));
416+
417+
public Style PopupStyle
418+
{
419+
get => (Style) GetValue(PopupStyleProperty);
420+
set => SetValue(PopupStyleProperty, value);
421+
}
422+
414423
public override void OnApplyTemplate()
415424
{
416425
if (_contentCoverGrid != null)

MaterialDesignThemes.Wpf/Themes/Generic.xaml

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,17 @@
470470
</Style.Triggers>
471471
</Style>
472472

473+
<Style x:Key="MaterialDesignDialogHostPopup" TargetType="{x:Type controlzEx:PopupEx}">
474+
<Setter Property="StaysOpen" Value="True" />
475+
<Setter Property="AllowsTransparency" Value="True" />
476+
<Setter Property="PopupAnimation" Value="None" />
477+
<Setter Property="Placement" Value="Center" />
478+
</Style>
479+
473480
<Style TargetType="{x:Type local:DialogHost}">
474481
<Setter Property="DialogMargin" Value="22" />
475482
<Setter Property="local:ShadowAssist.ShadowDepth" Value="Depth5" />
483+
<Setter Property="PopupStyle" Value="{StaticResource MaterialDesignDialogHostPopup}" />
476484
<Setter Property="Template">
477485
<Setter.Value>
478486
<ControlTemplate TargetType="local:DialogHost">
@@ -596,13 +604,9 @@
596604
</VisualState>
597605
</VisualStateGroup>
598606
</VisualStateManager.VisualStateGroups>
599-
<controlzEx:PopupEx IsOpen="False"
600-
PlacementTarget="{Binding ElementName=DialogHostRoot, Mode=OneWay}"
601-
StaysOpen="True"
602-
AllowsTransparency="True"
603-
PopupAnimation="None"
604-
x:Name="PART_Popup"
605-
Placement="Center">
607+
<controlzEx:PopupEx PlacementTarget="{Binding ElementName=DialogHostRoot, Mode=OneWay}"
608+
x:Name="PART_Popup"
609+
Style="{TemplateBinding PopupStyle}">
606610
<controlzEx:PopupEx.Resources>
607611
<ResourceDictionary>
608612
<ResourceDictionary.MergedDictionaries>

0 commit comments

Comments
 (0)