/DataBoundApp1/MainPage.xaml.cs
C# | 70 lines | 50 code | 10 blank | 10 comment | 5 complexity | a249892b634edf121084db844ecbc1db MD5 | raw file
- 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 DataBoundApp1.ViewModels;
- using Microsoft.Phone.Controls;
-
- namespace DataBoundApp1
- {
- public partial class MainPage : PhoneApplicationPage
- {
- // Constructor
- public MainPage()
- {
- InitializeComponent();
-
- // Set the data context of the listbox control to the sample data
- DataContext = App.ViewModel;
- this.Loaded += new RoutedEventHandler(MainPage_Loaded);
- }
-
- // Handle selection changed on ListBox
- private void MainListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- // If selected index is -1 (no selection) do nothing
- if (MainListBox.SelectedIndex == -1)
- return;
-
- // Navigate to the new page
- NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + ((SessionViewModel)MainListBox.SelectedItem).Uri, UriKind.Relative));
-
- // Reset selected index to -1 (no selection)
- MainListBox.SelectedIndex = -1;
- }
-
- // Load data for the ViewModel Sessions
- private void MainPage_Loaded(object sender, RoutedEventArgs e)
- {
- if (!App.ViewModel.IsDataLoaded)
- {
- App.ViewModel.LoadData();
- }
- }
-
- private void FavListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- // If selected index is -1 (no selection) do nothing
- if (FavListBox.SelectedIndex == -1)
- return;
-
- // Navigate to the new page
- NavigationService.Navigate(new Uri("/DetailsPage.xaml?selectedItem=" + ((SessionViewModel)FavListBox.SelectedItem).Uri, UriKind.Relative));
-
- // Reset selected index to -1 (no selection)
- FavListBox.SelectedIndex = -1;
- }
-
- private void txtSearchTerm_KeyUp(object sender, KeyEventArgs e)
- {
- App.ViewModel.FilterData(txtSearchTerm.Text);
- }
- }
- }