-3

A-->B

B+--->A+

2 番目の .XAML ファイルに移動し、最初のファイルのデータを失うことなく戻る方法はありますか?

4

4 に答える 4

3

状態を保存し、IsolatedStorage に格納されるApplicationSettingsを使用します。これは、廃棄されてもデータを存続させたい場合に使用するものです。または、一時的な状態で状態を保持することもできます。

于 2012-06-13T23:53:45.673 に答える
0

私が行う方法は、App.xaml.cs でいくつかのパブリック変数を宣言することです。

public partial class App : Application
{
    public var item;

    ...    
}

任意のページで ((App)(App.Current)).item として参照すると、別のページで変数にアクセスできます。

(一部の開発者は、グローバル変数を見てうんざりするかもしれませんが、まあ、うまくいきます)

于 2012-06-13T21:01:26.567 に答える
0

私が最後にしたことは、リストボックスをグローバル文字列変数に保存し、値をコンマで区切ってから、グローバル streang 変数を読み取って、データをリストボックスに戻すことだけでした。

データを文字列に保存する

//creating a string array
        string[] scores = new string[lsScore.Items.Count];
        //filling the string array with the data from the listbox
        lsScore.Items.CopyTo(scores, 0);
        //filling a string with the joined values seperated by comma
        string saveScores = string.Join(",", scores);
        //saving the data to the global variable
        saved.saveScores = saveScores;

文字列からデータを読み取る

// creating a an array and split the values from the global variable based on the comma
                string[] scores2 = saved.saveScores.Split(',');
                //adding the data to the lsitbox 
                foreach (string str in scores2)
                    lsScore.Items.Add(str);
于 2012-06-13T22:24:16.043 に答える
0

Server.Urlcode(parameter) パラメータ値を使用すると、+、->、& などの特殊記号を記述した値になります。

例:Response.redirect("~/default2.aspx?data" +server.Urlcode(txtdata.text))

于 2012-06-13T15:33:55.137 に答える