Skip to content

Conversation

@corvinsz
Copy link
Member

@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)

return new BlurEffect() { Radius = blurRadius };
}

return null;
Copy link
Member 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
Member 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!

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.

3 participants