You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I cant create a DropShadow behind a control. The shadow is always in front of it!
void ApplyDropShadow(FrameworkElement const& element) {
// Get the Compositor and Visual for the element
auto visual = ElementCompositionPreview::GetElementVisual(element);
auto compositor = visual.Compositor();
// Create a DropShadow
DropShadow dropShadow = compositor.CreateDropShadow();
dropShadow.Color(winrt::Windows::UI::ColorHelper::FromArgb(255, 0, 255, 255));
dropShadow.BlurRadius(30.0f);
dropShadow.Opacity(0.8f);
dropShadow.Offset({ -5.0f, -5.0f, 0.0f });
// Create a SpriteVisual and set the shadow
SpriteVisual shadowVisual = compositor.CreateSpriteVisual();
shadowVisual.Shadow(dropShadow);
// Set the size of the shadow to match the element
shadowVisual.Size({ element.ActualSize().x + 10, element.ActualSize().y + 10 });
// Place the container visual behind the XAML element
ElementCompositionPreview::SetElementChildVisual(element, shadowVisual);
}
Steps to reproduce the bug
execute code
Expected behavior
No response
Screenshots
No response
NuGet package version
None
Packaging type
No response
Windows version
No response
IDE
No response
Additional context
No response
The text was updated successfully, but these errors were encountered:
I cannot test in C++, but it is the same code as in C#; a way is to render the control with RenderTargetBitmap (similar to in this test #10062), then add the shadow (and Mask depending on the control (GetAlphaMask))
A test with an Image control, by adapting your code :
Describe the bug
I cant create a DropShadow behind a control. The shadow is always in front of it!
Steps to reproduce the bug
execute code
Expected behavior
No response
Screenshots
No response
NuGet package version
None
Packaging type
No response
Windows version
No response
IDE
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: