dotnet / wpf

WPF is a .NET Core UI framework for building Windows desktop applications.
MIT License
7.08k stars 1.17k forks source link

Feature Request: Inner shadow #2972

Open h82258652 opened 4 years ago

h82258652 commented 4 years ago

WPF only supports outer shadow. Here is a way to simulate inner shadow:

<!--  https://stackoverflow.com/questions/15500820/how-to-achieve-inset-shadow-effect-in-wpf/15500885  -->
<Border Background="LightGray" BorderBrush="DarkGray" 
           BorderThickness="1" ClipToBounds="True">
  <Border Background="Transparent" BorderBrush="Black" 
              BorderThickness="0 2 7 0" Margin="-2">
    <Border.Effect>
      <DropShadowEffect ShadowDepth="0" BlurRadius="10"/>
    </Border.Effect>
  </Border>
</Border>

But it is too hack. I hope WPF can support the inner shadow effect.

weltkante commented 4 years ago

DropShadowEffect is inefficient and not used by the builtin themes, they instead use SystemDropShadowChrome which is composed of gradients (linear gradients on edges, quarter circle gradients on corners)

The WPF repo didn't see much activity lately, so if you don't want to wait and solve it yourself you could built something analogue to SystemDropShadowChrome with gradients but composing inwards instead of outwards.