summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Controls/SimpleApp.cs
blob: aab454f7439b77674c9bf90d7a8443da916c4739 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Diagnostics;

namespace Xamarin.Forms.Controls
{
	public class SimpleApp : Application
	{
		public SimpleApp()
		{
			var label = new Label { VerticalOptions = LayoutOptions.CenterAndExpand };

			if (Current.Properties.ContainsKey("LabelText"))
			{
				label.Text = (string)Current.Properties["LabelText"] + " Restored!";
				Debug.WriteLine("Initialized");
			}
			else
			{
				Current.Properties["LabelText"] = "Wowza";
				label.Text = (string)Current.Properties["LabelText"] + " Set!";
				Debug.WriteLine("Saved");
			}

			MainPage = new ContentPage
			{
				Content = new StackLayout
				{
					Children =
					{
						label
					}
				}
			};

			SerializeProperties();
		}

		static async void SerializeProperties()
		{
			await Current.SavePropertiesAsync();
		}
	}
}