Isolated Storageを使用してWindows Phone 7アプリケーションを作成しました。このアプリケーションでは、btnReadという名前のボタン、txtReadという名前のテキストブロック、txtWriteという名前のテキストボックスを使用しました。テキストボックス(txtWrite)に何かを書き、ボタン(btnRead)をクリックした場合。次に、テキストブロック(txtRead)はテキストボックスに書き込むものを表示または保存します(これらはすべて1つのMainPage.xamlで作成されます)。今私は別のpage1.xamlを作成し、txtShowという名前のテキストブロックを作成しました。しかし、私は、TextBox(txtShow)にMainPage.xamlにあるテキストボックスに書き込むすべてのものを表示します。私も以下https://skydrive.live.com/redir.aspx?cid=ea5aaefa4ad2307a&resid=EA5AAEFA4AD2307A!133&parid=EA5AAEFA4AD2307A!109別のページにページの結果を表示したいですか?
は、私が使用しているMainPage.xaml.cs源である私のプロジェクト - をアップロードした - :
private void button1_Click(object sender, RoutedEventArgs e)
{
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
myStore.CreateDirectory("Bookmark");
using (var isoFileStream = new IsolatedStorageFileStream("Bookmark\\myFile.txt", FileMode.OpenOrCreate, myStore))
{
//Write the data
using (var isoFileWriter = new StreamWriter(isoFileStream))
{
isoFileWriter.WriteLine(txtWrite.Text);
}
}
try
{
// Specify the file path and options.
using (var isoFileStream = new IsolatedStorageFileStream("Bookmark\\myFile.txt", FileMode.Open, myStore))
{
// Read the data.
using (var isoFileReader = new StreamReader(isoFileStream))
{
txtRead.Text = isoFileReader.ReadLine();
}
}
}
catch
{
// Handle the case when the user attempts to click the Read button first.
txtRead.Text = "Need to create directory and the file first.";
}
}
テキストボックス(txtRead)の代わりにリストボックス(listBox1)を使用する場合はどうすればよいですか? – user1316766
それをListBoxに追加します:listBox.Items.Add(text); –