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

Feature - Blurry Dialog Background #3738

Merged

Conversation

corvinsz
Copy link
Contributor

@corvinsz corvinsz commented Dec 6, 2024

I recently came across @Keboo 's video (C#/Blazor - Trying out MudBlazor on an app) about MudBlazor, where they have implemented a Dialog that blurs the background if opened.
This is my aproach of implementing the above mechanism in MDIX.

API proposal

I added 2 new dependency properties to the DialogHost.cs:

<materialDesign:DialogHost ApplyBlurBackground="True"
                           BlurRadius="8"
                           ...>
</materialDesign:DialogHost>
Property Type Default value
ApplyBlurBackground Bool False
BlurRadius double 16

I essentially just added the 2 new dependency properties above, and some logic to apply a BlurEffect on the DialogHosts ContentPresenter.
The logic is contained in the newly added converter DialogBackgroundBlurConverter.

ApplyBlurBackground BlurRadius Default Style MaterialDesignEmbeddedDialogHost
True 16 (Default) image image
True 64 image image

I don't know why GitHub shows the images in the column "Default Style" in a smaller format, all images are the same exact size :-( (Apparently it's just the preview of the markdown that is not display it correctly)

Corvin Szimion added 10 commits October 24, 2024 10:55

Verified

This commit was signed with the committer’s verified signature.
dovydas55 Dovydas Stankevicius

Verified

This commit was signed with the committer’s verified signature.
dovydas55 Dovydas Stankevicius
This reverts commit ede38d4.

Verified

This commit was signed with the committer’s verified signature.
mathieuartu Mathieu Artu
-added DialogBackgroundBlurConverter
-Blurry Background working for both the "normal" DialogHost Style and the "MaterialDesignEmbeddedDialogHost"
return new BlurEffect() { Radius = blurRadius };
}

return null;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the "Build and Test" failing because I am returning null from this converter?
Should this rather be DependencyProperty.UnsetValue or Binding.DoNothing?
I am never sure on which one to use.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@corvinsz It's the analyzers yelling at you here. Basically you need to add a ? to the return type, the values parameter, and the parameter parameter to indicate nullability.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for clarifying @nicolaihenriksen
I'm still doing alot of .NET Framework 4.x work due to legacy projects and I always forget about the nullability in .NET 5+

Copy link
Member

@Keboo Keboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nicely done. One small comment then I think we can merge this.

@Keboo Keboo added enhancement release notes Items are likely to be highlighted in the release notes. labels Dec 10, 2024
@Keboo Keboo added this to the 5.2.0 milestone Dec 10, 2024
…nverter.cs


converter nullability

Co-authored-by: Kevin B <Keboo@users.noreply.github.com>
Copy link
Member

@Keboo Keboo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job, thank you!

@Keboo Keboo enabled auto-merge (squash) December 10, 2024 16:38
@Keboo Keboo merged commit 5df62fa into MaterialDesignInXAML:master Dec 10, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement release notes Items are likely to be highlighted in the release notes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants