I've defined a style for my buttons that incorporates using a dropshadow for depth. I've read online that this sometimes causes bluriness of the text, but can be resolved in WPF4 by using:
TextOptions.TextFormattingMode="Display"
However, the text in my buttons is not blurry, but it's not displaying correctly and the above code does nothing to improve the display.
With dropshadow:

Without dropshadow: 
The drop shadow is defined in a style that is applied to the buttons.
<Style TargetType="Button" x:Key="RedButton">
<Setter Property="SnapsToDevicePixels" Value="true" />
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="MinHeight" Value="25" />
<Setter Property="MinWidth" Value="70" />
<Setter Property="FontFamily" Value="Verdana" />
<Setter Property="FontSize" Value="14" />
<Setter Property="Foreground" Value="White" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border TextBlock.Foreground="{TemplateBinding Foreground}" x:Name="Border" CornerRadius="6" BorderThickness="1">
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Color="{StaticResource DarkRedColor}" Offset="1.0" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{StaticResource LightRedColor}" Offset="0.5" />
<GradientStop Color="{StaticResource DarkRedColor}" Offset="1" />
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect Color="Black" Opacity=".50" ShadowDepth="4" RenderingBias="Quality" />
</Border.Effect>.....
Think it's because of the DropShadowEffect trying to get applied to all children which I guess is where the ContentPresenter is in the Style
Try this:
<Style x:Key="RedButton"
TargetType="Button">
...
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid>
<Border x:Name="Border"
BorderThickness="1"
CornerRadius="6"
TextBlock.Foreground="{TemplateBinding Foreground}">
<Border.BorderBrush>
<LinearGradientBrush StartPoint="0,0"
EndPoint="0,1">
<LinearGradientBrush.GradientStops>
<GradientStopCollection>
<GradientStop Offset="1.0"
Color="{StaticResource DarkRedColor}" />
</GradientStopCollection>
</LinearGradientBrush.GradientStops>
</LinearGradientBrush>
</Border.BorderBrush>
<Border.Background>
<LinearGradientBrush StartPoint="0.5,0"
EndPoint="0.5,1">
<GradientStop Offset="0.5"
Color="{StaticResource LightRedColor}" />
<GradientStop Offset="1"
Color="{StaticResource DarkRedColor}" />
</LinearGradientBrush>
</Border.Background>
<Border.Effect>
<DropShadowEffect Opacity=".50"
RenderingBias="Quality"
ShadowDepth="4"
Color="Black" />
</Border.Effect>
</Border>
<Border BorderThickness="1"
CornerRadius="6"
TextBlock.Foreground="{TemplateBinding Foreground}">
<ContentPresenter />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With