From 65e441ff715d5d5483c6033c97d151236f4761bb Mon Sep 17 00:00:00 2001 From: Zhao Cheng Date: Mon, 5 Mar 2012 23:02:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E5=8C=BA=E7=83=AD=E7=82=B9=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E6=8C=89=E9=92=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HotPage.xaml | 2 +- HotPage.xaml.cs | 18 ++++++++++++------ ViewModels/MainViewModel.cs | 1 + 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/HotPage.xaml b/HotPage.xaml index b74bff6..9514d3d 100644 --- a/HotPage.xaml +++ b/HotPage.xaml @@ -82,7 +82,7 @@ - + diff --git a/HotPage.xaml.cs b/HotPage.xaml.cs index 8a566df..cc8eb55 100644 --- a/HotPage.xaml.cs +++ b/HotPage.xaml.cs @@ -19,14 +19,15 @@ namespace sbbs_client_wp7 public partial class HotPage : PhoneApplicationPage { - private HotViewModel viewModel = new HotViewModel(); - private bool isHotTopicsLoading = true; + private bool isHotTopicsLoading; public HotPage() { InitializeComponent(); - DataContext = viewModel; + if (App.ViewModel.Hot == null) + App.ViewModel.Hot = new HotViewModel(); + DataContext = App.ViewModel.Hot; } protected override void OnNavigatedTo(NavigationEventArgs e) @@ -39,7 +40,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) switch (type) { case 0: - if (viewModel.TopicsGroupItems == null) + if (App.ViewModel.Hot.TopicsGroupItems == null) LoadHotTopics(); break; } @@ -48,7 +49,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e) private void SetLoading() { - viewModel.IsLoading = isHotTopicsLoading; + App.ViewModel.Hot.IsLoading = isHotTopicsLoading; } private void LoadHotTopics() @@ -71,7 +72,7 @@ private void LoadHotTopics() newGroup.Add(newItem); } - viewModel.TopicsGroupItems = newGroup; + App.ViewModel.Hot.TopicsGroupItems = newGroup; } }); } @@ -92,5 +93,10 @@ private void LongListSelector_SelectionChanged(object sender, SelectionChangedEv new Uri("/TopicPage.xaml?board=" + topic.Board + "&id=" + topic.Id + "&title=" + HttpUtility.UrlEncode(topic.Title), UriKind.Relative)); } } + + private void Refresh_Click(object sender, EventArgs e) + { + LoadHotTopics(); + } } } \ No newline at end of file diff --git a/ViewModels/MainViewModel.cs b/ViewModels/MainViewModel.cs index 1d99124..3299e59 100644 --- a/ViewModels/MainViewModel.cs +++ b/ViewModels/MainViewModel.cs @@ -104,6 +104,7 @@ public ObservableCollection FavoratesItems public CurrentBoardViewModel CurrentBoard { get; set; } // 当前话题 public CurrentTopicViewModel CurrentTopic { get; set; } + public HotViewModel Hot { get; set; } // 是否已经登陆 public bool IsLogin