我正在 Windows Phone 7 中开发游戏。我想在主页上添加一个按钮,允许在图像之间切换。
我写了以下代码但不起作用
整数键 = 1;
switch (key)
{
case 1:
var brush = new ImageBrush();
BitmapImage image = new BitmapImage(new Uri(@"Assets/small/misc/music pause button.png", UriKind.Relative));
brush.ImageSource = image;
music.Background = brush;
key=0;
break;
case 0:
var brush2 = new ImageBrush();
BitmapImage image2 = new BitmapImage(new Uri(@"Assets/small/misc/music pause button.png", UriKind.Relative));
brush2.ImageSource = image2;
music.Background = brush2;
key = 1;
break;
}