문제

I want to make a simple note taking app for Windows Phone 8.

My question is: How do I make the text that the user puts into the textbox stay inside the textbox even if the app is suspended or deactivated?

Help is appreciated.

도움이 되었습니까?

해결책

try using IsolatedStorage for saving your user's notes inside phone's memory and try getting them back when your app is launched again. Here is a link that will help you get through IsolatedStorage MSDN Link Another Project

Example code from the second link:

Storing:

private void Button_Click_2(object sender, RoutedEventArgs e)
{
    IsolatedStorageSettings isoStoreSettings = IsolatedStorageSettings.ApplicationSettings;
    int integerValue;
    int.TryParse(Entier.Text, out integerValue);
    //store the integer
    isoStoreSettings["IntegerValue"] = integerValue;
    //store the string
    isoStoreSettings["StringValue"] = chaine.Text;
}

Retrieving:

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    IsolatedStorageSettings isoStoreSettings = IsolatedStorageSettings.ApplicationSettings;
    int integerValue;
    string stringValue;

    //Retreive The integer
    if (isoStoreSettings.TryGetValue("IntegerValue", out integerValue))
    {
        Entier.Text = integerValue.ToString();
    }

    //Retreive the string
    if (isoStoreSettings.TryGetValue("StringValue", out stringValue))
    {
        chaine.Text = stringValue;
    }
    isoStoreSettings.Save();
} 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top