Can you define a shadow in a style?

Jeff Pfahl 91 Reputation points
2023-12-15T17:58:11.19+00:00

I want to define a shadow for a border in styles so I can adjust it for light and dark mode. I can't find the syntax for this.

Developer technologies | .NET | .NET MAUI
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-12-18T02:50:10.6066667+00:00

    Hello,

    I want to define a shadow for a border in styles so I can adjust it for light and dark mode.

    You can define a shadow for a border, then change the shadow's property for the light mode and dark mode.

    For example, Please open Styles.xaml, then find the <Style TargetType="Border">, add a Shadow like following code. I define different colors of Brush and values of Opacity for different themes.

       <Style TargetType="Border">
          ...
            <Setter Property="Shadow">
                <Shadow           
                    Brush="{AppThemeBinding Light={StaticResource Gray200}, Dark={StaticResource Magenta}}"
                    Opacity="{AppThemeBinding Light=1, Dark=0.5}"
                    Radius="50"               
                    />
            </Setter>
        </Style>
    

    Best Regards,

    Leon Lu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.