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

DropShadow Documentation for use in C# code #663

Open
jhwheuer opened this issue Sep 5, 2022 · 0 comments
Open

DropShadow Documentation for use in C# code #663

jhwheuer opened this issue Sep 5, 2022 · 0 comments

Comments

@jhwheuer
Copy link

jhwheuer commented Sep 5, 2022

So I am deprecating the old DropShadowPanel in favor of the the AttachedDropShadow Effect.

Only, I am doing it in C# code, not XAML, as my users can place shapes on a canvas arbitrarily. So I do not have a pre-designed XAML element to attach the DropShadow to...

Running this code does not produce a shadow.:

public static void InitShadow(FrameworkElement e, float blurRadius, float opacity, Vector3 offset, Windows.UI.Color color)
        {
            if (e != null)
            {
                AttachedDropShadow shadow = new AttachedDropShadow()
                {
                    Opacity = opacity,
                    BlurRadius = blurRadius,
                    Offset = offset.ToString(),
                    Color = color,
                    IsMasked = true
                };

                e.SetValue(Effects.ShadowProperty, shadow);
            }
        }

The shapes can be irregular (e.g. a partially transparent bitmap) so that DropShadow needs to be able to deal with that...

When this code is run, the shape is already attached to and positioned on a Canvas.

Any way you could expand the XAML-only documentation for us struggling C# folks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant