
MainPage.xaml.cs
By:
meredithleu on
May 25th, 2012 | syntax:
C# | size: 1.84 KB | hits: 21 | expires: Never
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Collections.ObjectModel;
namespace MentalStack
{
public partial class MainPage : PhoneApplicationPage
{
private ObservableCollection<Note> thoughts;
public ObservableCollection<Note> Thoughts{
get
{
if (thoughts == null)
{
thoughts = new ObservableCollection<Note>();
}
return thoughts;
}
}
// Constructor
public MainPage()
{
InitializeComponent();
Note item = new Note("hi", "just testing");
thoughts = new ObservableCollection<Note>();
thoughts.Add(new Note("aaa", "BBB"));
}
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
if (PhoneApplicationService.Current.State.ContainsKey("Thoughts"))
{
thoughts = (ObservableCollection<Note>)PhoneApplicationService.Current.State["Thoughts"];
}
}
protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
{
PhoneApplicationService.Current.State["Thoughts"] = thoughts;
base.OnNavigatedFrom(e);
}
private void addThought(object sender, EventArgs e)
{
NavigationService.Navigate(new Uri("/PageAddThought.xaml", UriKind.Relative));
}
}
}