Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# WPF为什么按钮';按下后,屏幕背景是否闪烁?_C#_Wpf - Fatal编程技术网

C# WPF为什么按钮';按下后,屏幕背景是否闪烁?

C# WPF为什么按钮';按下后,屏幕背景是否闪烁?,c#,wpf,C#,Wpf,我创建了一个用户控件,并在其中添加了一个按钮,删除了背景和文本属性: <Button x:Name="Button" HorizontalAlignment="Center" Height="40" VerticalAlignment="Center" Width="40" RenderTransformOrigin="0,-2" Margin="0,0,0,0" BorderB

我创建了一个
用户控件
,并在其中添加了一个
按钮
,删除了
背景
文本
属性:

<Button x:Name="Button"
        HorizontalAlignment="Center"
        Height="40"
        VerticalAlignment="Center"
        Width="40"
        RenderTransformOrigin="0,-2"
        Margin="0,0,0,0"
        BorderBrush="{x:Null}"
        Click="Button_Click"
        Background="{x:Null}"/>
上面的代码用另一个
UserControl
填充
按钮
内容,这是一个简单的交叉图片

我已将带有
按钮的
用户控件
放入主窗口应用程序,按下
按钮后,它开始闪烁-背景在两种颜色之间流畅地变化。除此之外,我的代码功能运行良好。我只是不知道如何摆脱那种闪烁的背景

单击之前: 单击后:

您可以在
按钮上设置
Focusable=“False”
来实现这一点


但是您应该阅读中的
Focusable
属性,以检查它是否适合您。我想你不能再使用tab键对焦
按钮了。但这对您来说可能不是问题。

这似乎是Windows 7的标准行为(如果您在个人设置中选择了Aero主题),并且是一个重复的问题。看见
private void Button_Click(object sender, RoutedEventArgs e)
{
    Button.Content = new cross();
}