能给我完整的示例代码吗
时间: 2023-08-07 22:20:16 浏览: 52
当然可以,以下是一个完整的示例代码,演示如何使用样式去掉按钮的蓝色遮罩效果:
```xml
<Window x:Class="WpfApp1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Width="200" Height="100">
<Window.Resources>
<Style TargetType="Button">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
</Style>
</Window.Resources>
<Grid>
<Button Content="My Button" Margin="10"/>
</Grid>
</Window>
```
在这个示例代码中,我们在Window的资源文件中定义了一个样式,将Button的FocusVisualStyle属性设置为Null,从而去掉了蓝色遮罩效果。然后我们在Grid中添加了一个Button控件,并将其样式设置为上面定义的样式。
当您运行这个示例代码时,您会发现按钮的蓝色遮罩效果已经被去掉了。如果您需要去掉其他控件的蓝色遮罩效果,也可以使用类似的方式来定义样式。