/// The methods provided in this section are simply used to allow
        /// NavigationHelper to respond to the page's navigation methods.
        ///
        /// Page specific logic should be placed in event handlers for the
        /// <see cref="Common.NavigationHelper.LoadState"/>
        /// and <see cref="Common.NavigationHelper.SaveState"/>.
        /// The navigation parameter is available in the LoadState method
        /// in addition to page state preserved during an earlier session.

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            ComicQuery comicQuery = e.Parameter as ComicQuery;

            if (comicQuery != null)
            {
                comicQueryManager.UpdateQueryResults(comicQuery);
                pageTitle.Text = comicQueryManager.Title;
            }
            navigationHelper.OnNavigatedTo(e);
        }
        private void OnListViewItemClick(object sender, ItemClickEventArgs e)
        {
            ComicQuery query = e.ClickedItem as ComicQuery;

            if (query != null)
            {
                SuspensionManager.CurrentQuery = query.Title;
                if (query.Title == "All comics in the collection")
                {
                    this.Frame.Navigate(typeof(QueryDetailZoom), query);
                }
                else
                {
                    this.Frame.Navigate(typeof(QueryDetail), query);
                }
            }
        }
        public void UpdateQueryResults(ComicQuery query)
        {
            Title = query.Title;
            switch (query.Title)
            {
            case "LINQ makes queries easy":
                LinqMakesQueryEasy();
                break;

            case "Expensive comics":
                ExpensiveComics();
                break;

            case "LINQ is versatile 1":
                LinqIsVersatile1();
                break;

            case "LINQ is versatile 2":
                LinqIsVersatile2();
                break;

            case "LINQ is versatile 3":
                LinqIsVersatile3();
                break;

            case "Group comics by price range":
                GroupComicsByRange();
                break;

            case "Join purchases with prices":
                JoinPurchasesWithPrices();
                break;

            case "All comics in the collection":
                AllComics();
                break;
            }
        }
        /// <summary>
        /// Invoked when the application is launched normally by the end user.  Other entry points
        /// will be used when the application is launched to open a specific file, to display
        /// search results, and so forth.
        /// </summary>
        /// <param name="e">Details about the launch request and process.</param>
        async protected override void OnLaunched(LaunchActivatedEventArgs e)
        {
#if DEBUG
            if (System.Diagnostics.Debugger.IsAttached)
            {
                this.DebugSettings.EnableFrameRateCounter = true;
            }
#endif

            Frame rootFrame = Window.Current.Content as Frame;

            // Do not repeat app initialization when the Window already has content,
            // just ensure that the window is active
            if (rootFrame == null)
            {
                // Create a Frame to act as the navigation context and navigate to the first page
                rootFrame = new Frame();

                // TODO: change this value to a cache size that is appropriate for your application
                rootFrame.CacheSize = 1;

                if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
                {
                    // TODO: Load state from previously suspended application
                    await SuspensionManager.RestoreAsync();
                }

                // Place the frame in the current Window
                Window.Current.Content = rootFrame;
            }

            if (rootFrame.Content == null)
            {
#if WINDOWS_PHONE_APP
                // Removes the turnstile navigation for startup.
                if (rootFrame.ContentTransitions != null)
                {
                    this.transitions = new TransitionCollection();
                    foreach (var c in rootFrame.ContentTransitions)
                    {
                        this.transitions.Add(c);
                    }
                }

                rootFrame.ContentTransitions = null;
                rootFrame.Navigated         += this.RootFrame_FirstNavigated;
#endif

                // When the navigation stack isn't restored navigate to the first page,
                // configuring the new page by passing required information as a navigation
                // parameter
                rootFrame.Navigate(typeof(MainPage), e.Arguments);
                if (!String.IsNullOrEmpty(SuspensionManager.CurrentQuery))
                {
                    var currentQuerySequenz = from query in new ComicQueryManager().AvailableQueries where query.Title == SuspensionManager.CurrentQuery select query;
                    if (currentQuerySequenz.Count() == 1)
                    {
                        ComicQuery query = currentQuerySequenz.First();
                        if (query != null)
                        {
                            if (query.Title == "All comics in the collection")
                            {
                                rootFrame.Navigate(typeof(QueryDetailZoom), query);
                            }
                            else
                            {
                                rootFrame.Navigate(typeof(QueryDetail), query);
                            }
                        }
                    }
                }
            }

            // Ensure the current window is active
            Window.Current.Activate();
        }