문제

I'm porting my game "Bustin' Jieber" on Windows Phone to Windows 8, and I have to do a isolated storage-like system to hold the settings, records and the money. I'm using this on windows phone:

IsolatedStorageSettings iosystem = IsolatedStorageSetting.ApplicationSettings;

and for example the money system;

iosystem["bjc"] = (int.Parse(iosystem["bjc"].ToString()) + (points * int.Parse(iosystem["pointduplication"].ToString())));

How can I implement this into my code? Please give me a usable code (with namespaces or so) ! Thanks! also, app is c#...

도움이 되었습니까?

해결책

You can use ApplicationData.Current.LocalSettings;

Sample Code:

Windows.Storage.ApplicationDataContainer localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;

// Create a simple setting

localSettings.Values["exampleSetting"] = "Hello Windows";

// Read data from a simple setting

Object value = localSettings.Values["exampleSetting"];

if (value == null)
{
    // No data
}
else
{
    // Access data in value
}

// Delete a simple setting

localSettings.Values.Remove("exampleSetting");

& here is relevant post from MSDN

Apart from this you can try this from CodePlex [I didn't tried this before]

다른 팁

By said by kumar, you can use ApplicationData stuff, but let me show you an easier version based on kumar's answer:

Windows.Foundation.Collections.IPropertySet setting = Windows.Storage.ApplicationData.Current.LocalSettings.Values;

and just replace localsettings.Values (on kumar's answer) to setting. Good luck people :)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top