我在我的应用程序中创建了一个带有图像的按钮:
<Button x:Name="favoriteButton" HorizontalAlignment="Left" VerticalAlignment="Top" Height="72" Width="99" Click="DidPressAddToFavorites" BorderBrush="{x:Null}" Foreground="{x:Null}">
<Button.Background>
<ImageBrush ImageSource="/Images/favouritesBWIcon@2x.png" Stretch="Uniform"/>
</Button.Background>
</Button>
我注意到,当用户按下按钮时,所有按钮都变成蓝色,当我释放按钮时,我又看到了它。知道如何解决吗?
编辑:
这是处理程序方法:
private void DidPressAddToFavorites(object sender, RoutedEventArgs e)
{
if (favoriteRep.ExistInFavorites(currentItem) == true)
{
this.SetButtonWithImage(favoriteButton, "/Images/favouritesBWIcon@2x.png");
favoriteRep.RemoveFromFavorites(currentItem);
}
else
{
this.SetButtonWithImage(favoriteButton, "/Images/favouritesIcon@2x.png");
favoriteRep.AddToFavorites(currentItem);
}
}