I've created style for button in my WPF app:
<Style x:Key="buttonStyle" TargetType="Button">
<Setter Property="Border.BorderBrush" Value="Black" />
<Setter Property="Border.BorderThickness" Value="1" />
<Setter Property="Border.Background" Value="White" />
<Setter Property="Height" Value="25" />
<Setter Property="Width" Value="100" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border
Width="{TemplateBinding Width}"
Height="{TemplateBinding Height}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<ContentPresenter
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{TemplateBinding Content}"
ContentTemplate="{TemplateBinding ContentTemplate}" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Then I'm putting this style to Button control:
<Button Style="{StaticResource buttonStyle}" Grid.Row="1" Grid.Column="1" Content="Press"/>
When I'm running my app, I see grey shadow under and right of the button. Futhermore when I look in Visual Studio view I don't see shadow. How can I delete this effect? Anyone an idea or an completly other approach?
Are you sure what you're seeing is actually a shadow? It could simply be a blurred edge. WPF's layout system is based on device-independent pixels, so it's possible for an element's edge to reside between two device pixels, in which case it may appear blurred.
You can force device-pixel snapping by setting UseLayoutRounding="True"
on a parent element in WPF 4.0 and later; in earlier versions, you can try SnapsToDevicePixels="True"
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments