Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Showcase blurry Dialog in demo #3748

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions src/MainDemo.Wpf/Dialogs.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -315,5 +315,58 @@
</materialDesign:DialogHost>
</smtx:XamlDisplay>
<!--#endregion-->

<Rectangle Style="{StaticResource PageSectionSeparator}" />

<!--#region SAMPLE 6-->
<TextBlock Style="{StaticResource PageSectionTitleTextBlock}" Text="Sample 6" />

<TextBlock MaxWidth="700"
Margin="0,0,0,8"
HorizontalAlignment="Left"
Text="You can also make the background blurry."
TextWrapping="Wrap" />

<DockPanel Margin="0,5,16,5">
<Button Margin="8,0,0,0"
Click="Sample6_ResetBlur"
Content="{materialDesign:PackIcon Kind=Reload}"
DockPanel.Dock="Right"
Style="{StaticResource MaterialDesignFlatButton}"
ToolTip="Reset the BlurRadius of the Dialogs Background to it's default value" />
<Slider x:Name="BlurRadiusSlider"
HorizontalAlignment="Stretch"
DockPanel.Dock="Left"
Maximum="64"
Minimum="1"
Style="{StaticResource MaterialDesignDiscreteSlider}" />

</DockPanel>

<smtx:XamlDisplay UniqueKey="dialogs_sample6">
<materialDesign:DialogHost VerticalAlignment="Center"
ApplyBlurBackground="True"
BlurRadius="{Binding ElementName=BlurRadiusSlider, Path=Value}"
CloseOnClickAway="True"
Identifier="sampleDialog6">
<Border MinWidth="256"
MinHeight="256"
BorderBrush="{DynamicResource PrimaryHueMidBrush}"
BorderThickness="1"
ClipToBounds="True">
<StackPanel VerticalAlignment="Center">
<TextBlock HorizontalAlignment="Center"
FontSize="30"
Text="This is some long text that is going to get blurred out by the dialog."
TextWrapping="Wrap" />
<Button HorizontalAlignment="Center"
VerticalAlignment="Center"
Click="Sample6_OpenDialog"
Content="Open" />
</StackPanel>
</Border>
</materialDesign:DialogHost>
</smtx:XamlDisplay>
<!--#endregion-->
</StackPanel>
</UserControl>
16 changes: 16 additions & 0 deletions src/MainDemo.Wpf/Dialogs.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public Dialogs()
{
DataContext = new DialogsViewModel();
InitializeComponent();
BlurRadiusSlider.Value = DialogHost.DefaultBlurRadius;
}

private void Sample1_DialogHost_OnDialogClosing(object sender, DialogClosingEventArgs eventArgs)
Expand Down Expand Up @@ -71,4 +72,19 @@ private void Sample5_DialogHost_OnDialogClosed(object sender, DialogClosedEventA
if (!string.IsNullOrWhiteSpace(AnimalTextBox.Text))
AnimalListBox.Items.Add(AnimalTextBox.Text.Trim());
}

private async void Sample6_OpenDialog(object sender, RoutedEventArgs e)
{
var sampleMessageDialog = new SampleMessageDialog
{
Message = { Text = "Some dialog content" }
};

await DialogHost.Show(sampleMessageDialog, "sampleDialog6");
}

private void Sample6_ResetBlur(object sender, RoutedEventArgs e)
{
BlurRadiusSlider.Value = DialogHost.DefaultBlurRadius;
}
}
2 changes: 1 addition & 1 deletion src/MaterialDesignThemes.Wpf/DialogHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ public bool ApplyBlurBackground
nameof(ApplyBlurBackground), typeof(bool), typeof(DialogHost), new PropertyMetadata(default(bool)));


private const double DefaultBlurRadius = 16.0;
public const double DefaultBlurRadius = 16.0;
public double BlurRadius
{
get => (double)GetValue(BlurRadiusProperty);
Expand Down
Loading