summaryrefslogtreecommitdiff
path: root/Juick
diff options
context:
space:
mode:
Diffstat (limited to 'Juick')
-rw-r--r--Juick/MainPage.xaml8
-rw-r--r--Juick/MainPage.xaml.cs12
-rw-r--r--Juick/ViewModels/AppViewModel.cs14
3 files changed, 25 insertions, 9 deletions
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 @@
<phone:PhoneApplicationPage
x:Class="Juick.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:bindings="clr-namespace:Juick.Classes"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:phoneshell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
+ xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:usercontrols="clr-namespace:Juick.Controls" xmlns:classes="clr-namespace:Juick.Classes"
@@ -29,6 +31,12 @@
</Grid.RowDefinitions>
<TextBlock Text="Network unavailable" Visibility="{Binding NetworkUnavailable, Converter={StaticResource BooleanToVisibilityConverter}}" />
<controls:Pivot x:Name="Pages" Title="juick" Grid.Row="2" ItemsSource="{Binding Pages}">
+ <i:Interaction.Triggers>
+ <i:EventTrigger EventName="SelectionChanged">
+ <bindings:InvokeDelegateCommandAction Command="{Binding CheckNewDataCommand}"
+ CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}"/>
+ </i:EventTrigger>
+ </i:Interaction.Triggers>
<controls:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Caption}"></TextBlock>
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<SelectionChangedEventArgs>(CheckNewData, () => Account.IsAuthenticated);
}
private ObservableCollection<PageViewModel> _pages;
public ObservableCollection<PageViewModel> Pages
@@ -133,6 +135,8 @@ namespace Juick.ViewModels
}
}
+ public DelegateCommand<SelectionChangedEventArgs> 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();
+ }
}
}