diff --git a/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs b/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs
index 89181c746a..50b53b8045 100644
--- a/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs
+++ b/MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs
@@ -6,12 +6,8 @@
namespace MaterialDesignThemes.UITests.WPF.DialogHosts;
-public class DialogHostTests : TestBase
+public class DialogHostTests(ITestOutputHelper output) : TestBase(output)
{
- public DialogHostTests(ITestOutputHelper output) : base(output)
- {
- }
-
[Fact]
public async Task OnOpenDialog_OverlayCoversContent()
{
@@ -480,4 +476,61 @@ public async Task DialogHost_ChangesSelectedRailItem_DoesNotPerformRailChangeWhe
recorder.Success();
}
+
+ [Theory]
+ [InlineData("MaterialDesignElevatedCard")]
+ [InlineData("MaterialDesignOutlinedCard")]
+ [Description("Issue 3430")]
+ public async Task DialogHost_DefaultStyleWithDialogCardStyleApplied_PassesStyleToNestedCard(string dialogCardStyle)
+ {
+ await using var recorder = new TestRecorder(App);
+
+ IVisualElement grid = await LoadXaml($$"""
+
+
+
+
+
+
+
+
+
+
+ """);
+
+ IVisualElement dialogHost = await grid.GetElement("DialogHost");
+ IVisualElement nestedCard = await dialogHost.GetElement("PART_PopupContentElement");
+
+ Assert.Equal(new Thickness(42), await nestedCard.GetPadding());
+
+ recorder.Success();
+ }
+
+ [Theory]
+ [InlineData("MaterialDesignElevatedCard")]
+ [InlineData("MaterialDesignOutlinedCard")]
+ [Description("Issue 3430")]
+ public async Task DialogHost_EmbeddedStyleWithDialogCardStyleApplied_PassesStyleToNestedCard(string dialogCardStyle)
+ {
+ await using var recorder = new TestRecorder(App);
+
+ IVisualElement grid = await LoadXaml($$"""
+
+
+
+
+
+
+
+ """);
+
+ IVisualElement dialogHost = await grid.GetElement("DialogHost");
+ IVisualElement nestedCard = await dialogHost.GetElement("PART_PopupContentElement");
+
+ // TODO: Assert the style on the nested card matches what is set in DialogHost.DialogCardStyle
+
+ recorder.Success();
+ }
}
diff --git a/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs b/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs
index cfc94767c2..b6cc44e812 100644
--- a/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs
+++ b/MaterialDesignThemes.Wpf.Tests/DialogHostTests.cs
@@ -1,7 +1,6 @@
using System.ComponentModel;
using System.Threading;
using System.Windows.Threading;
-using Xunit;
namespace MaterialDesignThemes.Wpf.Tests;
diff --git a/MaterialDesignThemes.Wpf/DialogHost.cs b/MaterialDesignThemes.Wpf/DialogHost.cs
index 96b851d3d9..6f885255ba 100644
--- a/MaterialDesignThemes.Wpf/DialogHost.cs
+++ b/MaterialDesignThemes.Wpf/DialogHost.cs
@@ -483,7 +483,7 @@ public string? DialogContentStringFormat
}
public static readonly DependencyProperty DialogMarginProperty = DependencyProperty.Register(
- "DialogMargin", typeof(Thickness), typeof(DialogHost), new PropertyMetadata(default(Thickness)));
+ nameof(DialogMargin), typeof(Thickness), typeof(DialogHost), new PropertyMetadata(default(Thickness)));
public Thickness DialogMargin
{
@@ -494,6 +494,15 @@ public Thickness DialogMargin
public static readonly DependencyProperty OpenDialogCommandDataContextSourceProperty = DependencyProperty.Register(
nameof(OpenDialogCommandDataContextSource), typeof(DialogHostOpenDialogCommandDataContextSource), typeof(DialogHost), new PropertyMetadata(default(DialogHostOpenDialogCommandDataContextSource)));
+ public static readonly DependencyProperty DialogCardStyleProperty = DependencyProperty.Register(
+ nameof(DialogCardStyle), typeof(Style), typeof(DialogHost), new PropertyMetadata(default(Style)));
+
+ public Style DialogCardStyle
+ {
+ get => (Style) GetValue(DialogCardStyleProperty);
+ set => SetValue(DialogCardStyleProperty, value);
+ }
+
///
/// Defines how a data context is sourced for a dialog if a
/// is passed as the command parameter when using .
@@ -505,7 +514,7 @@ public DialogHostOpenDialogCommandDataContextSource OpenDialogCommandDataContext
}
public static readonly DependencyProperty CloseOnClickAwayProperty = DependencyProperty.Register(
- "CloseOnClickAway", typeof(bool), typeof(DialogHost), new PropertyMetadata(default(bool)));
+ nameof(CloseOnClickAway), typeof(bool), typeof(DialogHost), new PropertyMetadata(default(bool)));
///
/// Indicates whether the dialog will close if the user clicks off the dialog, on the obscured background.
@@ -517,7 +526,7 @@ public bool CloseOnClickAway
}
public static readonly DependencyProperty CloseOnClickAwayParameterProperty = DependencyProperty.Register(
- "CloseOnClickAwayParameter", typeof(object), typeof(DialogHost), new PropertyMetadata(default(object)));
+ nameof(CloseOnClickAwayParameter), typeof(object), typeof(DialogHost), new PropertyMetadata(default(object)));
///
/// Parameter to provide to close handlers if an close due to click away is instigated.
@@ -529,7 +538,7 @@ public object? CloseOnClickAwayParameter
}
public static readonly DependencyProperty SnackbarMessageQueueProperty = DependencyProperty.Register(
- "SnackbarMessageQueue", typeof(SnackbarMessageQueue), typeof(DialogHost), new PropertyMetadata(default(SnackbarMessageQueue), SnackbarMessageQueuePropertyChangedCallback));
+ nameof(SnackbarMessageQueue), typeof(SnackbarMessageQueue), typeof(DialogHost), new PropertyMetadata(default(SnackbarMessageQueue), SnackbarMessageQueuePropertyChangedCallback));
private static void SnackbarMessageQueuePropertyChangedCallback(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
{
@@ -642,7 +651,7 @@ public bool IsRestoreFocusDisabled
public static readonly RoutedEvent DialogOpenedEvent =
EventManager.RegisterRoutedEvent(
- "DialogOpened",
+ nameof(DialogOpened),
RoutingStrategy.Bubble,
typeof(DialogOpenedEventHandler),
typeof(DialogHost));
@@ -689,7 +698,7 @@ protected void OnDialogOpened(DialogOpenedEventArgs eventArgs)
public static readonly RoutedEvent DialogClosingEvent =
EventManager.RegisterRoutedEvent(
- "DialogClosing",
+ nameof(DialogClosing),
RoutingStrategy.Bubble,
typeof(DialogClosingEventHandler),
typeof(DialogHost));
@@ -732,7 +741,7 @@ protected void OnDialogClosing(DialogClosingEventArgs eventArgs)
public static readonly RoutedEvent DialogClosedEvent =
EventManager.RegisterRoutedEvent(
- "DialogClosed",
+ nameof(DialogClosed),
RoutingStrategy.Bubble,
typeof(DialogClosedEventHandler),
typeof(DialogHost));
diff --git a/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml
index 0171246280..69d1a21449 100644
--- a/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml
+++ b/MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml
@@ -158,8 +158,8 @@
-
-
-
@@ -228,6 +220,9 @@
+
+
+
@@ -406,6 +401,7 @@
@@ -424,16 +421,6 @@
-
-
-
@@ -441,6 +428,9 @@
+
+
+