Refactor GroupBox elevation #3217
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in discussion #3201, there is something that does not work as expected with the elevation in combination with
GroupBox.The demo app already includes a sample of a
GroupBoxwith elevation only applied on the header (ColorZone), so I am assuming this is a needed feature, and thus this PR will retain it.However, if the
GroupBoxhas a border, or a background, or is using the "card" style, then I would also assume elevation should work, but that does not seem to be the case.It currently looks like this:

You'll notice that the elevation is still only applied at the header. This seems wrong to me.
This PR changes it into this instead:

Since the drop shadow is done using an
DropShadowEffect, there is a bit of funkyness to this. If theGroupBox.Backgroundproperty is left at its default value (Transparent), then the effect is applied only at the header to retain the current feature. However, if the it is set to any other value, then the effect is applied at the root grid instead, which effectively - in the case of a "reasonably opaque" brush - will let the shadow cover the whole body of theGroupBox. You can of course provide a funky value with a very low opacity and then you may not get the result you want. I could not really see any other good way to solve this. Hints/input is very welcome.Another thing: I removed the use of the
ShadowAssist.ShadowEdgesattached property as I don't believe it has any effect. Perhaps it needs to be removed completely as part of the 5.0 release?