Skip to content

Commit 8ae308c

Browse files
corvinszCorvin Szimion
andauthored
Showcase blurry Dialog in demo (#3748)
* Cleanup of launchSettings and Cards Page in Demo * Revert "Cleanup of launchSettings and Cards Page in Demo" This reverts commit ede38d4. * added a new DialogHost to showcase the blurred background of a DialogHost in the demo app * made DialogHost.DefaultBlurRadius constant public * added button to reset the BlurRadius --------- Co-authored-by: Corvin Szimion <[email protected]>
1 parent 10ebc6f commit 8ae308c

File tree

3 files changed

+70
-1
lines changed

3 files changed

+70
-1
lines changed

src/MainDemo.Wpf/Dialogs.xaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,5 +315,58 @@
315315
</materialDesign:DialogHost>
316316
</smtx:XamlDisplay>
317317
<!--#endregion-->
318+
319+
<Rectangle Style="{StaticResource PageSectionSeparator}" />
320+
321+
<!--#region SAMPLE 6-->
322+
<TextBlock Style="{StaticResource PageSectionTitleTextBlock}" Text="Sample 6" />
323+
324+
<TextBlock MaxWidth="700"
325+
Margin="0,0,0,8"
326+
HorizontalAlignment="Left"
327+
Text="You can also make the background blurry."
328+
TextWrapping="Wrap" />
329+
330+
<DockPanel Margin="0,5,16,5">
331+
<Button Margin="8,0,0,0"
332+
Click="Sample6_ResetBlur"
333+
Content="{materialDesign:PackIcon Kind=Reload}"
334+
DockPanel.Dock="Right"
335+
Style="{StaticResource MaterialDesignFlatButton}"
336+
ToolTip="Reset the BlurRadius of the Dialogs Background to it's default value" />
337+
<Slider x:Name="BlurRadiusSlider"
338+
HorizontalAlignment="Stretch"
339+
DockPanel.Dock="Left"
340+
Maximum="64"
341+
Minimum="1"
342+
Style="{StaticResource MaterialDesignDiscreteSlider}" />
343+
344+
</DockPanel>
345+
346+
<smtx:XamlDisplay UniqueKey="dialogs_sample6">
347+
<materialDesign:DialogHost VerticalAlignment="Center"
348+
ApplyBlurBackground="True"
349+
BlurRadius="{Binding ElementName=BlurRadiusSlider, Path=Value}"
350+
CloseOnClickAway="True"
351+
Identifier="sampleDialog6">
352+
<Border MinWidth="256"
353+
MinHeight="256"
354+
BorderBrush="{DynamicResource PrimaryHueMidBrush}"
355+
BorderThickness="1"
356+
ClipToBounds="True">
357+
<StackPanel VerticalAlignment="Center">
358+
<TextBlock HorizontalAlignment="Center"
359+
FontSize="30"
360+
Text="This is some long text that is going to get blurred out by the dialog."
361+
TextWrapping="Wrap" />
362+
<Button HorizontalAlignment="Center"
363+
VerticalAlignment="Center"
364+
Click="Sample6_OpenDialog"
365+
Content="Open" />
366+
</StackPanel>
367+
</Border>
368+
</materialDesign:DialogHost>
369+
</smtx:XamlDisplay>
370+
<!--#endregion-->
318371
</StackPanel>
319372
</UserControl>

src/MainDemo.Wpf/Dialogs.xaml.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public Dialogs()
1010
{
1111
DataContext = new DialogsViewModel();
1212
InitializeComponent();
13+
BlurRadiusSlider.Value = DialogHost.DefaultBlurRadius;
1314
}
1415

1516
private void Sample1_DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventArgs)
@@ -71,4 +72,19 @@ private void Sample5_DialogHost_OnDialogClosed(object sender, DialogClosedEventA
7172
if (!string.IsNullOrWhiteSpace(AnimalTextBox.Text))
7273
AnimalListBox.Items.Add(AnimalTextBox.Text.Trim());
7374
}
75+
76+
private async void Sample6_OpenDialog(object sender, RoutedEventArgs e)
77+
{
78+
var sampleMessageDialog = new SampleMessageDialog
79+
{
80+
Message = { Text = "Some dialog content" }
81+
};
82+
83+
await DialogHost.Show(sampleMessageDialog, "sampleDialog6");
84+
}
85+
86+
private void Sample6_ResetBlur(object sender, RoutedEventArgs e)
87+
{
88+
BlurRadiusSlider.Value = DialogHost.DefaultBlurRadius;
89+
}
7490
}

src/MaterialDesignThemes.Wpf/DialogHost.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ public bool ApplyBlurBackground
607607
nameof(ApplyBlurBackground), typeof(bool), typeof(DialogHost), new PropertyMetadata(default(bool)));
608608

609609

610-
private const double DefaultBlurRadius = 16.0;
610+
public const double DefaultBlurRadius = 16.0;
611611
public double BlurRadius
612612
{
613613
get => (double)GetValue(BlurRadiusProperty);

0 commit comments

Comments
 (0)