This is kind of driving me insane. Adding a DropShadowEffect
to a button. In the IDE it looks like this:
Second button is for reference with no DropShadowEffect
. As you can see there next no difference. Then I build the project and when it runs it looks like this:
What is causing this change? Here is the XAML for the two buttons:
<Button Name="clearButton" Content="Clear" Click="clearButton_Click" Margin="5,0,5,0" MaxWidth="80" MinHeight="40"
TextOptions.TextFormattingMode="Display">
<Button.Effect>
<DropShadowEffect BlurRadius="5" ShadowDepth="3" />
</Button.Effect>
</Button>
<Button Content="Clear" Margin="5,5,5,0" MaxWidth="80" MinHeight="40" TextOptions.TextFormattingMode="Display" />
Edit: Taking @gretro does make it look better but it still is not right:
Yet once again in the IDE it looks fine:
Your entire button is rendering on a cross-pixel boundary. Note how the 1-point border actually spans multiple pixels, causing a blurring effect.
Try setting UseLayoutRounding="True"
on a parent or ancestor element. The further up the tree, the better (your view's root visual would be ideal). You can also try SnapsToDevicePixels="True"
.