I have a WPF borderless window with a shadow set to the grid shown below:
<Window x:Class="Wpf.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525" WindowStyle="None"
AllowsTransparency="True" Background="Transparent" BorderThickness="0">
<Grid>
<Grid.Effect>
<DropShadowEffect BlurRadius="15" Direction="-90" RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
</Grid>
</Window>
However, when the BorderThickness is set to 0, the shadow doesn't appear. When I increase this, the shadow will appear, but when the window is moved to the edge of the screen using DragMove(), a gap is left (presumably the width of BorderThickness).
How can I, therefore, add a shadow around the window with BorderThickness set to 0? Thanks in advance.
<Window x:Class="WpfApp7.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WpfApp7"
mc:Ignorable="d" WindowStyle="None"
AllowsTransparency="True" Background="Transparent" BorderThickness="0"
Title="MainWindow" Height="450" Width="800">
<Grid Margin="10">
<Grid.Background>
<SolidColorBrush Color="Green" Opacity="1"/>
</Grid.Background>
<Grid.Effect>
<DropShadowEffect Color="Black" BlurRadius="15" Direction="-90"
RenderingBias="Quality" ShadowDepth="2"/>
</Grid.Effect>
</Grid>
:) just add margin to the grid. It needs space to show the shadow.