アプリの背景をランダムに変更するボタン( 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;
}
誰でもこれを手伝ってもらえますか?ご協力いただきありがとうございます!