Removing shadow from button WPF

wsc

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?

Mike Strobel

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Removing the shadow from a button

From Java

Removing the drop shadow from a Scaffold AppBar in Flutter?

From Dev

Removing default shadow from search box

From Dev

Removing box shadow from element using jquery

From Dev

Removing box shadow from element using jquery

From Dev

Removing outer border of toggle button wpf

From Dev

Removing up button from Actionbar

From Dev

CSS triangle and box shadow removing from a specific area

From Dev

Removing an item from a WPF binding listbox

From Dev

Dynamically removing an item from an observable collection - WPF

From Dev

Removing the shadow created by a dialog

From Dev

iOS - Removing UITabBarViewController Shadow

From Dev

Removing button from Angularjs UI bootstrap datepicker

From Dev

Removing padding from toggle button in Android

From Dev

Removing Item From Basket Opencart Custom button

From Dev

Removing image from button misplaces text

From Dev

Removing the cancel button from Custom camera

From Dev

Removing the little box from a toggle button

From Dev

Removing button from Angularjs UI bootstrap datepicker

From Dev

Removing Item From Basket Opencart Custom button

From Dev

Removing image from button misplaces text

From Dev

Removing the 'selection' from a radio button in a listview control

From Dev

Removing the little box from a toggle button

From Dev

Removing item from Datagrid view with delete button

From Dev

WPF passing button content from button?

From Dev

Remove shadow from ActiveX Option Button in Excel 2010 VBA

From Dev

Removing Bottom Shadow Bootstrap Navbar

From Dev

Removing bottom shadow on ActionBar - Android

From Dev

Android - removing shadow on pressed animation

Related Related

HotTag

Archive