From 98700f28bb208f7bdc741397b1c9993bfd051d8d Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 27 Nov 2013 00:48:37 +0400 Subject: Refresh only current page, fixes issue #18 --- Juick/MainPage.xaml | 8 ++++++++ Juick/MainPage.xaml.cs | 12 +++++------- Juick/ViewModels/AppViewModel.cs | 14 ++++++++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) (limited to 'Juick') diff --git a/Juick/MainPage.xaml b/Juick/MainPage.xaml index d2c99df..840f8ae 100644 --- a/Juick/MainPage.xaml +++ b/Juick/MainPage.xaml @@ -1,10 +1,12 @@  + + + + + diff --git a/Juick/MainPage.xaml.cs b/Juick/MainPage.xaml.cs index 7baa6dd..edf2d3b 100644 --- a/Juick/MainPage.xaml.cs +++ b/Juick/MainPage.xaml.cs @@ -45,8 +45,9 @@ namespace Juick BindingOperations.SetBinding( progressIndicator, ProgressIndicator.IsIndeterminateProperty, binding); if (App.AppContext.Account.IsAuthenticated) - foreach (var page in ((AppViewModel)DataContext).Pages) - page.RefreshData(); + { + App.AppContext.Pages[0].RefreshData(); + } }; } @@ -86,11 +87,8 @@ namespace Juick private void ApplicationBarIconButtonClick(object sender, EventArgs e) { - foreach (var page in App.AppContext.Pages) - { - page.Items.Clear(); - page.RefreshData(); - } + App.AppContext.Pages[Pages.SelectedIndex].Items.Clear(); + App.AppContext.Pages[Pages.SelectedIndex].RefreshData(); } private void ApplicationBarMenuItemClick(object sender, EventArgs e) diff --git a/Juick/ViewModels/AppViewModel.cs b/Juick/ViewModels/AppViewModel.cs index 2aff819..ba33625 100644 --- a/Juick/ViewModels/AppViewModel.cs +++ b/Juick/ViewModels/AppViewModel.cs @@ -10,6 +10,7 @@ using RestSharp; using Microsoft.Phone.Notification; using System.Diagnostics; using System.Text; +using System.Windows.Controls; namespace Juick.ViewModels { @@ -98,7 +99,8 @@ namespace Juick.ViewModels } Debug.WriteLine("Received: " + message.ToString()); }; - } + } + CheckNewDataCommand = new DelegateCommand(CheckNewData, () => Account.IsAuthenticated); } private ObservableCollection _pages; public ObservableCollection Pages @@ -133,6 +135,8 @@ namespace Juick.ViewModels } } + public DelegateCommand CheckNewDataCommand { get; private set; } + private AccountManager _acc; public AccountManager Account @@ -172,6 +176,12 @@ namespace Juick.ViewModels if (pushChannel.IsShellToastBound) pushChannel.UnbindToShellToast(); Account.NotificationUri = string.Empty; - } + } + + public void CheckNewData(SelectionChangedEventArgs param) + { + var page = param.AddedItems[0] as PageViewModel; + page.RefreshData(); + } } } -- cgit v1.2.3