WPF中的按钮悬停图像问题
我试图改变一个按钮的形象时,有一个鼠标悬停在我似乎无法让它工作。我已经完成了使蓝色色调在按钮悬停时不出现,但现在无法改变图像。我在这里读了很多关于它的帖子,也参考了其他的例子,但我无法让它起作用。当我使用下面的代码并将鼠标悬停在按钮上时,图像保持不变,不会更改为指定的新图像。想法 蓝色调去除WPF中的按钮悬停图像问题,wpf,vb.net,Wpf,Vb.net,我试图改变一个按钮的形象时,有一个鼠标悬停在我似乎无法让它工作。我已经完成了使蓝色色调在按钮悬停时不出现,但现在无法改变图像。我在这里读了很多关于它的帖子,也参考了其他的例子,但我无法让它起作用。当我使用下面的代码并将鼠标悬停在按钮上时,图像保持不变,不会更改为指定的新图像。想法 蓝色调去除 <Window.Resources> <Style x:Key="ButtonStyleNoHighlighting" TargetType="Button">
<Window.Resources>
<Style x:Key="ButtonStyleNoHighlighting" TargetType="Button">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Grid Background="{TemplateBinding Background}">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal"/>
<VisualState x:Name="MouseOver"/>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
按钮悬停图像
<Button x:Name="btnCloseApp"
Click="Application_Close"
Style="{StaticResource ButtonStyleNoHighlighting}">
<Button.Background>
<ImageBrush ImageSource="Resources/BTN_Close.png"/>
</Button.Background>
<Button.Resources>
<ControlTemplate x:Key="BackgroundButton" TargetType="Button">
<Border Name="border" BorderThickness="1" BorderBrush="Black" Background="{TemplateBinding Background}">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center" />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background">
<Setter.Value>
<ImageBrush ImageSource="Resources/BTN_Close_Hover.png" />
</Setter.Value>
</Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Button.Resources>
</Button>
任何帮助都将不胜感激 请在以下位置查看答案:。最好的问候,完美!我以前确实看到过这个,但把它误认为是我看到的另一个例子。为了减少源代码的使用,有没有一种方法可以为具有不同按钮图像的不同按钮执行此操作,或者我需要为每个按钮重复此操作?我很高兴它对您有效。如果你有更多的问题,我建议你单独发布。我最好的,