Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/flash/4.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
Windows phone 7 windows phone 7。。播放或暂停音乐_Windows Phone 7 - Fatal编程技术网

Windows phone 7 windows phone 7。。播放或暂停音乐

Windows phone 7 windows phone 7。。播放或暂停音乐,windows-phone-7,Windows Phone 7,我正在用WindowsPhone7开发游戏。我想在主页上添加一个按钮,允许在图像之间切换 我写了以下代码,但不起作用 int键=1 switch (key) { case 1: var brush = new ImageBrush(); BitmapImage image = new BitmapImage(new Uri(@"Assets/small/misc/music pau

我正在用WindowsPhone7开发游戏。我想在主页上添加一个按钮,允许在图像之间切换

我写了以下代码,但不起作用

int键=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;

        }

通过使用togglebutton解决了这个问题

在xaml中有切换按钮控件

现在在事件处理程序上添加代码:

    private void tog_Checked(object sender, RoutedEventArgs e)
    {

        tog.Background = brush;
        togkey = 1;
        System.Diagnostics.Debug.WriteLine("1");
    }

    private void tog_Unchecked(object sender, RoutedEventArgs e)
    {

        tog.Background = null;
        togkey = 0;
        System.Diagnostics.Debug.WriteLine("0");
    }

在这两种情况下,使用相同的图像(music pause button.png)是否正常?另外,你还应该描述什么“不起作用”,(它崩溃了吗?图像没有改变?图像没有显示?,,其他一些…)thnx它解决了…实际上我在循环中放置了key=1…所以每次它都是1而不是0