Skip to content

Commit 23eb009

Browse files
authored
Allow font settings to be inherited into the DialogHost (#2399)
Fixes #2398
1 parent b9562c4 commit 23eb009

File tree

2 files changed

+48
-8
lines changed

2 files changed

+48
-8
lines changed

MaterialDesignThemes.UITests/WPF/DialogHosts/DialogHostTests.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,5 +66,53 @@ public async Task ClosingDialogWithIsOpenProperty_ShouldRaiseDialogClosingEvent(
6666
await Wait.For(async () => Assert.Equal("1", await resultTextBlock.GetText()));
6767
recorder.Success();
6868
}
69+
70+
[Fact]
71+
[Description("Issue 2398")]
72+
public async Task FontSettingsSholdInheritIntoDialog()
73+
{
74+
await using var recorder = new TestRecorder(App);
75+
76+
IVisualElement grid = await LoadXaml<Grid>(@"
77+
<Grid TextElement.FontSize=""42""
78+
TextElement.FontFamily=""Times New Roman""
79+
TextElement.FontWeight=""ExtraBold"">
80+
<Grid.ColumnDefinitions>
81+
<ColumnDefinition />
82+
<ColumnDefinition />
83+
</Grid.ColumnDefinitions>
84+
<materialDesign:DialogHost>
85+
<materialDesign:DialogHost.DialogContent>
86+
<TextBlock Text=""Some Text"" x:Name=""TextBlock1"" />
87+
</materialDesign:DialogHost.DialogContent>
88+
<Button Content=""Show Dialog"" x:Name=""ShowButton1"" Command=""{x:Static materialDesign:DialogHost.OpenDialogCommand}"" />
89+
</materialDesign:DialogHost>
90+
<materialDesign:DialogHost Style=""{StaticResource MaterialDesignEmbeddedDialogHost}"" Grid.Column=""1"">
91+
<materialDesign:DialogHost.DialogContent>
92+
<TextBlock Text=""Some Text"" x:Name=""TextBlock2"" />
93+
</materialDesign:DialogHost.DialogContent>
94+
<Button Content=""Show Dialog"" x:Name=""ShowButton2"" Command=""{x:Static materialDesign:DialogHost.OpenDialogCommand}"" />
95+
</materialDesign:DialogHost>
96+
</Grid>");
97+
var showButton1 = await grid.GetElement<Button>("ShowButton1");
98+
var showButton2 = await grid.GetElement<Button>("ShowButton2");
99+
100+
await showButton1.LeftClick();
101+
await showButton2.LeftClick();
102+
await Task.Delay(300);
103+
104+
var text1 = await grid.GetElement<TextBlock>("TextBlock1");
105+
var text2 = await grid.GetElement<TextBlock>("TextBlock2");
106+
107+
Assert.Equal(42, await text1.GetFontSize());
108+
Assert.True((await text1.GetFontFamily())?.FamilyNames.Values.Contains("Times New Roman"));
109+
Assert.Equal(FontWeights.ExtraBold, await text1.GetFontWeight());
110+
111+
Assert.Equal(42, await text2.GetFontSize());
112+
Assert.True((await text2.GetFontFamily())?.FamilyNames.Values.Contains("Times New Roman"));
113+
Assert.Equal(FontWeights.ExtraBold, await text2.GetFontWeight());
114+
115+
recorder.Success();
116+
}
69117
}
70118
}

MaterialDesignThemes.Wpf/Themes/MaterialDesignTheme.DialogHost.xaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -156,10 +156,6 @@
156156
wpf:ShadowAssist.ShadowDepth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth)}"
157157
UniformCornerRadius="4"
158158
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
159-
TextElement.FontWeight="Regular"
160-
TextElement.FontSize="13"
161-
TextOptions.TextFormattingMode="Ideal"
162-
TextOptions.TextRenderingMode="Auto"
163159
FocusManager.IsFocusScope="False"
164160
Foreground="{DynamicResource MaterialDesignBody}"
165161
Focusable="True"
@@ -360,10 +356,6 @@
360356
wpf:ShadowAssist.ShadowDepth="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=(wpf:ShadowAssist.ShadowDepth)}"
361357
UniformCornerRadius="4"
362358
TextElement.Foreground="{DynamicResource MaterialDesignBody}"
363-
TextElement.FontWeight="Regular"
364-
TextElement.FontSize="13"
365-
TextOptions.TextFormattingMode="Ideal"
366-
TextOptions.TextRenderingMode="Auto"
367359
FocusManager.IsFocusScope="False"
368360
Foreground="{DynamicResource MaterialDesignBody}"
369361
Focusable="True"

0 commit comments

Comments
 (0)