private void populate(List <Book> books)
        {
            ViewModel = new ViewModel();

            foreach (Book b in books)
            {
                ViewModel.Books.Add(b);
            }
            this.DataContext = ViewModel;
            ItemDetailFrame.Navigate(typeof(NoItemSelected));
            BookListLabel.Text = String.Format("Books Found ({0})", books.Count());

            ViewModel.PropertyChanged += (sender, args) =>
            {
                if (args.PropertyName == "SelectedItemIndex")
                {
                    if (ViewModel.SelectedItemIndex == -1)
                    {
                        ItemDetailFrame.Navigate(typeof(NoItemSelected));
                    }
                    else
                    {
                        ItemDetailFrame.Navigate(typeof(ItemDetail), ViewModel);
                    }
                }
            };
        }
        public ListPage()
        {
            viewModel = new ViewModel();

            viewModel.StoreList.Add("Whole Foods");
            viewModel.StoreList.Add("Kroger");
            viewModel.StoreList.Add("Costco");
            viewModel.StoreList.Add("Walmart");

            viewModel.GroceryList.Add(new GroceryItem {
                Name     = "Apples",
                Quantity = 4, Store = "Whole Foods"
            });
            viewModel.GroceryList.Add(new GroceryItem {
                Name     = "Hotdogs",
                Quantity = 12, Store = "Costco"
            });
            viewModel.GroceryList.Add(new GroceryItem {
                Name     = "Soda",
                Quantity = 2, Store = "Costco"
            });
            viewModel.GroceryList.Add(new GroceryItem {
                Name     = "Eggs",
                Quantity = 12, Store = "Kroger"
            });

            this.InitializeComponent();

            this.DataContext = viewModel;

            ItemDetailFrame.Navigate(typeof(NoItemSelected));
            viewModel.PropertyChanged += (sender, args) => {
                if (args.PropertyName == "SelectedItemIndex")
                {
                    if (viewModel.SelectedItemIndex == -1)
                    {
                        ItemDetailFrame.Navigate(typeof(NoItemSelected));
                    }
                    else
                    {
                        ItemDetailFrame.Navigate(typeof(ItemDetail), viewModel);
                    }
                }
            };
        }
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            viewModel = (ViewModel)e.Parameter;

            ItemDetailFrame.Navigate(typeof(NoItemSelected));
            viewModel.PropertyChanged += (sender, args) => {
                if (args.PropertyName == "SelectedItemIndex")
                {
                    if (viewModel.SelectedItemIndex == -1)
                    {
                        ItemDetailFrame.Navigate(typeof(NoItemSelected));
                        AppBarDoneButton.IsEnabled = false;
                    }
                    else
                    {
                        ItemDetailFrame.Navigate(typeof(ItemDetail), viewModel);
                        AppBarDoneButton.IsEnabled = true;
                    }
                }
            };
        }