WPF按钮删除"模糊"从按钮

时间:2018-03-01 18:12:35

标签: c# wpf xaml

您好我试图在我的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>

1 个答案:

答案 0 :(得分:2)

解决方案是删除此行

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

此效果是在内容中创建了一些边框