Well, here is one long way to implement a rectangular “shadow” without using a bitmap effect. In this case, the center of the “shadow rectangle” is painted into it, but it can be set to transparency to give you a “shadow” shadow of the “halo” style (that is, it is equal with the whole circle, not the offset).
<UserControl x:Class="RectShadow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib"> <UserControl.Resources> <System:Double x:Key="CornerSize">5</System:Double> <Color x:Key="ShadowColor">#60000000</Color> <Color x:Key="TransparentColor">#00000000</Color> </UserControl.Resources> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition/> <ColumnDefinition Width="auto"/> </Grid.ColumnDefinitions> <Rectangle Width="{StaticResource CornerSize}" Height="{StaticResource CornerSize}"> <Rectangle.Fill> <RadialGradientBrush Center="1,1" GradientOrigin="1,1" RadiusX="1" RadiusY="1"> <GradientStop Color="{StaticResource ShadowColor}"/> <GradientStop Offset="1" Color="{StaticResource TransparentColor}"/> </RadialGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Row="2" Grid.Column="2" Width="{StaticResource CornerSize}" Height="{StaticResource CornerSize}"> <Rectangle.Fill> <RadialGradientBrush Center="0,0" GradientOrigin="0,0" RadiusX="1" RadiusY="1"> <GradientStop Color="{StaticResource ShadowColor}"/> <GradientStop Offset="1" Color="{StaticResource TransparentColor}"/> </RadialGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Row="0" Grid.Column="2" Width="{StaticResource CornerSize}" Height="{StaticResource CornerSize}"> <Rectangle.Fill> <RadialGradientBrush Center="0,1" GradientOrigin="0,1" RadiusX="1" RadiusY="1"> <GradientStop Color="{StaticResource ShadowColor}"/> <GradientStop Offset="1" Color="{StaticResource TransparentColor}"/> </RadialGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Row="2" Grid.Column="0" Width="{StaticResource CornerSize}" Height="{StaticResource CornerSize}"> <Rectangle.Fill> <RadialGradientBrush Center="1,0" GradientOrigin="1,0" RadiusX="1" RadiusY="1"> <GradientStop Color="{StaticResource ShadowColor}"/> <GradientStop Offset="1" Color="{StaticResource TransparentColor}"/> </RadialGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Column="1"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0,1"> <GradientStop Offset="1" Color="{StaticResource ShadowColor}"/> <GradientStop Color="{StaticResource TransparentColor}"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Column="1" Grid.Row="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="0,1"> <GradientStop Color="{StaticResource ShadowColor}"/> <GradientStop Offset="1" Color="{StaticResource TransparentColor}"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Row="1"> <Rectangle.Fill> <LinearGradientBrush EndPoint="1,0"> <GradientStop Offset="1" Color="{StaticResource ShadowColor}"/> <GradientStop Color="{StaticResource TransparentColor}"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Row="1" Grid.Column="2"> <Rectangle.Fill> <LinearGradientBrush EndPoint="1,0"> <GradientStop Color="{StaticResource ShadowColor}"/> <GradientStop Offset="1" Color="{StaticResource TransparentColor}"/> </LinearGradientBrush> </Rectangle.Fill> </Rectangle> <Rectangle Grid.Row="1" Grid.Column="1"> <Rectangle.Fill> <SolidColorBrush Color="{StaticResource ShadowColor}"/> </Rectangle.Fill> </Rectangle> </Grid> </UserControl>
source share