/
AlbumsPage.xaml.cs
65 lines (55 loc) · 2.18 KB
/
AlbumsPage.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Windows.Navigation;
using MediaControl.Client.WindowsPhone.ViewModels;
using MediaControl.Client.WindowsPhone.MediaLibrary;
namespace MediaControl.Client.WindowsPhone
{
public partial class AlbumsPage : PhoneApplicationPage
{
private object _selectedItem;
public AlbumsPage()
{
InitializeComponent();
SupportedOrientations = SupportedPageOrientation.Portrait;
Loaded += new RoutedEventHandler(MainPage_Loaded);
PageTransitionList.Completed += new EventHandler(PageTransitionList_Completed);
// Set the data context of the listbox control to the album list
DataContext = new AlbumsViewModel();
}
private void MainPage_Loaded(object sender, RoutedEventArgs e)
{
((AlbumsViewModel)DataContext).Albums.Clear();
((AlbumsViewModel)DataContext).LoadAlbums();
// Reset page transition
ResetPageTransitionList.Begin();
}
private void PageTransitionList_Completed(object sender, EventArgs e)
{
// Set datacontext of details page to selected listbox item
NavigationService.Navigate(new Uri("/AlbumPage.xaml", UriKind.Relative));
FrameworkElement root = Application.Current.RootVisual as FrameworkElement;
root.DataContext = new AlbumViewModel(_selectedItem as Album);
}
private void ListBoxOne_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
// Capture selected item data
_selectedItem = (sender as ListBox).SelectedItem;
if (_selectedItem != null)
{
// Start page transition animation
PageTransitionList.Begin();
}
}
}
}