Skip to content

Commit

Permalink
保存上一次的数据
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Mar 3, 2012
1 parent 34680aa commit c861b3e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using System.Collections.ObjectModel;

namespace sbbs_client_wp7
{
using Sbbs;

public partial class App : Application
{
private static MainViewModel viewModel = null;
Expand Down Expand Up @@ -89,6 +92,9 @@ public App()
// This code will not execute when the application is reactivated
private void Application_Launching(object sender, LaunchingEventArgs e)
{
// 载入上一次的数据状态
ViewModel.FavoratesItems = LocalCache.Get<ObservableCollection<BoardViewModel>>("Favorates");
ViewModel.ToptenItems = LocalCache.Get<ObservableCollection<TopicViewModel>>("Topten");
}

// Code to execute when the application is activated (brought to foreground)
Expand All @@ -108,6 +114,8 @@ private void Application_Deactivated(object sender, DeactivatedEventArgs e)
// This code will not execute when the application is deactivated
private void Application_Closing(object sender, ClosingEventArgs e)
{
LocalCache.Set<ObservableCollection<BoardViewModel>>("Favorates", ViewModel.FavoratesItems);
LocalCache.Set<ObservableCollection<TopicViewModel>>("Topten", ViewModel.ToptenItems);
}

// Code to execute if a navigation fails
Expand Down

0 comments on commit c861b3e

Please sign in to comment.