Skip to content

Commit

Permalink
分区热点刷新按钮
Browse files Browse the repository at this point in the history
  • Loading branch information
zcbenz committed Mar 5, 2012
1 parent 6ef081a commit 65e441f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion HotPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
<shell:ApplicationBarIconButton IconUri="/Images/refresh.png" Text="刷新"/>
<shell:ApplicationBarIconButton Click="Refresh_Click" IconUri="/Images/refresh.png" Text="刷新"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>

Expand Down
18 changes: 12 additions & 6 deletions HotPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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;
}
Expand All @@ -48,7 +49,7 @@ protected override void OnNavigatedTo(NavigationEventArgs e)

private void SetLoading()
{
viewModel.IsLoading = isHotTopicsLoading;
App.ViewModel.Hot.IsLoading = isHotTopicsLoading;
}

private void LoadHotTopics()
Expand All @@ -71,7 +72,7 @@ private void LoadHotTopics()
newGroup.Add(newItem);
}

viewModel.TopicsGroupItems = newGroup;
App.ViewModel.Hot.TopicsGroupItems = newGroup;
}
});
}
Expand All @@ -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();
}
}
}
1 change: 1 addition & 0 deletions ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public ObservableCollection<BoardViewModel> FavoratesItems
public CurrentBoardViewModel CurrentBoard { get; set; }
// 当前话题
public CurrentTopicViewModel CurrentTopic { get; set; }
public HotViewModel Hot { get; set; }

// 是否已经登陆
public bool IsLogin
Expand Down

0 comments on commit 65e441f

Please sign in to comment.