【问题标题】:Retrieving the custom background images on wp7 on start up在启动时检索 wp7 上的自定义背景图像
【发布时间】:2012-08-09 16:07:14
【问题描述】:

我添加了一个按钮(BackgroundBrowser)来随机更改我的应用程序的背景。但是当我退出并重新启动应用程序时,用户设置的最后一个图像与当前背景图像不同。我不知道如何检索在我的应用程序中设置的最后一张图片并将其设为当前背景图片。以下是我用来随机更改背景的代码。

private void BackgroundBrowser_Click(object sender, RoutedEventArgs e)
    {
        string imguri = "";

        click_count = click_count % 5;
        switch (click_count)
        {
            case 0: imguri = "Image/bg.jpg"; break;
            case 1: imguri = "Image/bg1.jpg"; break;
            case 2: imguri = "Image/bg3.jpg"; break;
            case 3: imguri = "Image/bg2.jpg"; break;
            case 4: imguri = ""; break;
        }
        click_count++;

        var app = Application.Current as App;
        app.appBmp = new BitmapImage(new Uri(imguri, UriKind.Relative));
        ImageBrush imageBrush = new ImageBrush();
        imageBrush.Stretch = Stretch.UniformToFill;
        imageBrush.Opacity = 0.7;
        imageBrush.ImageSource = app.appBmp;
        this.LayoutRoot.Background = imageBrush;
        app.appbrush = imageBrush;
        app.backchanged = true;
    }

有人可以帮忙吗?感谢您的帮助!

【问题讨论】:

    标签: c# windows-phone-7


    【解决方案1】:

    只需将其保存在独立存储中即可。例如,保存 uri 字符串(“Images/bg.jpg”),然后在重新启动应用时,检查 IsolatedStorage 中是否有值,读取它,然后相应地设置背景。

    Isolated Storage

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-12-15
      • 1970-01-01
      • 1970-01-01
      • 2012-12-11
      • 2013-10-13
      • 2011-02-18
      • 1970-01-01
      相关资源
      最近更新 更多