WPF按钮从按钮中删除“模糊”

问题描述 投票:1回答:1

嗨,我正在尝试在我的wpf中个性化按钮,因为当用户将鼠标悬停在按钮上时,它会显示“默认样式”,如下图所示

enter image description here

由于我不希望在按钮中鼠标结束时显示默认的蓝色和边框元素,因此我将此样式创建为我的按钮

<Style x:Key="Simple" TargetType="Button">

    <Setter Property="Template">
        <Setter.Value>
            <ControlTemplate TargetType="Button">
                <Border SnapsToDevicePixels="True" CornerRadius="3" Background="{TemplateBinding Background}" BorderBrush="#399bff" BorderThickness="0">
                    <Border.Effect>
                        <DropShadowEffect ShadowDepth="0" BlurRadius="0"></DropShadowEffect>
                    </Border.Effect>

                    <Grid SnapsToDevicePixels="True">

                        <Path SnapsToDevicePixels="True" Width="9" Height="16.5" Stretch="Fill"  HorizontalAlignment="Left" Margin="16.5,0,0,0"  Opacity="0">

                        </Path>
                        <Path SnapsToDevicePixels="True" x:Name="PathIcon" Width="8" Height="15"  Stretch="Fill"  HorizontalAlignment="Left" Margin="17,0,0,0">

                        </Path>

                        <ContentPresenter SnapsToDevicePixels="True" Content="{TemplateBinding Content}" ></ContentPresenter>
                    </Grid>
                </Border>
                <ControlTemplate.Triggers>
                    <Trigger Property="IsMouseOver" Value="True">
                        <Setter Property="Background" Value="Transparent"></Setter>
                        <Setter Property="BorderBrush" Value="Transparent"></Setter>
                        <Setter Property="Opacity" Value="0.8"></Setter>
                        <Setter Property="SnapsToDevicePixels" Value="True"></Setter>
                    </Trigger>
                </ControlTemplate.Triggers>
            </ControlTemplate>
        </Setter.Value>
    </Setter>
</Style>

但它在我的按钮中创建了某种模糊或边框,你可以在这张图片中的NF-e按钮(左边的蓝色按钮)中看到

enter image description here

它应该与CT-e按钮一样(右橙色)

我的XAML风格有什么问题?

编辑

按钮XAML代码

<Border  HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10 10 5 5" BorderThickness="0" Width="150" Height="150" Background="#992086bf" CornerRadius="10">
        <Button Style="{StaticResource Simple}" Click="GoToNFeEntrada" Background="Transparent" BorderBrush="Transparent">
            <Grid Width="150" Height="150">
                <fa:ImageAwesome Icon="File" Width="50" Foreground="White" VerticalAlignment="Top" Margin="0 30 0 0"></fa:ImageAwesome>
                <Label VerticalAlignment="Bottom" Margin="10 0 0 5" FontSize="15" Foreground="White">NF-e</Label>
            </Grid>
        </Button>
    </Border>
c# wpf xaml
1个回答
2
投票

解决方案是删除此行

<Border.Effect>
     <DropShadowEffect ShadowDepth="0" BlurRadius="0"></DropShadowEffect>
</Border.Effect>

这种影响在内容中创造了一些边界

© www.soinside.com 2019 - 2024. All rights reserved.