title: windows 8 app Back Button causes navigation fail
body: <p>I am completely new to developing windows 8 app, and this would be the first project I am working on so bear with me. I have started with a gridview template and attempted to create a class which stores cards and decks. Therefore, each deck is an item in the grid view and by clicking on a deck, it would change to a detail view where the deck's content are shown. Here in lies my problem. When I navigate to my detail view, (which only displays a title thus far) shows a back button, which as far as I know is automatically handled. However, whenever I press the back button to go to my grid view, I am hit with an unhandled exception of </p>
  
  <pre><code>Exception = {"Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"}
  </code></pre>
  
  <p><code>Message = "Windows.UI.Xaml.Controls.Frame.NavigationFailed was unhandled."</code></p>
  
  <p>My detailed view xaml and cs are as follows:</p>
  
  <p>DetailPage.xaml.cs
      using FlashcardBuddy.Data;
      using System;
      using System.Collections.Generic;
      using System.IO;
      using System.Linq;
      using Windows.Foundation;
      using Windows.Foundation.Collections;
      using Windows.UI.Xaml;
      using Windows.UI.Xaml.Controls;
      using Windows.UI.Xaml.Controls.Primitives;
      using Windows.UI.Xaml.Data;
      using Windows.UI.Xaml.Input;
      using Windows.UI.Xaml.Media;
      using Windows.UI.Xaml.Navigation;</p>
  
  <pre><code>// The Item Detail Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234232
  
  namespace FlashcardBuddy
  {
  
      public sealed partial class ItemDetailPage : FlashcardBuddy.Common.LayoutAwarePage
      {
          public ItemDetailPage()
          {
              this.InitializeComponent();
          }
  
          protected override void LoadState(Object navigationParameter, Dictionary&lt;String, Object&gt; pageState)
          {
              // Allow saved page state to override the initial item to display
              if (pageState != null &amp;&amp; pageState.ContainsKey("SelectedItem"))
              {
                  navigationParameter = pageState["SelectedItem"];
              }
  
              // TODO: Create an appropriate data model for your problem domain to replace the sample data
              var item = SampleDataSource.GetItem((String)navigationParameter);
  
              this.DefaultViewModel["Group"] = item;
              this.DefaultViewModel["Items"] = item.Items;
              //this.flipView.SelectedItem = item.Items[0];
          }
  
  
          protected override void SaveState(Dictionary&lt;String, Object&gt; pageState)
          {
              var selectedItem = (Card)this.flipView.SelectedItem;
              pageState["SelectedItem"] = selectedItem.id;
          }
      }
  }
  </code></pre>
  
  <p>DetailPage.xaml: </p>
  
  <pre><code>&lt;common:LayoutAwarePage
      x:Name="pageRoot"
      x:Class="FlashcardBuddy.ItemDetailPage"
      DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:local="using:FlashcardBuddy"
      xmlns:data="using:FlashcardBuddy.Data"
      xmlns:common="using:FlashcardBuddy.Common"
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
      mc:Ignorable="d"&gt;
  
      &lt;Page.Resources&gt;
  
          &lt;!-- Collection of items displayed by this page --&gt;
          &lt;CollectionViewSource
              x:Name="itemsViewSource"
              Source="{Binding Items}"
              d:Source="{Binding AllGroups[0].Items[0].Items, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/&gt;
      &lt;/Page.Resources&gt;
  
      &lt;!--
          This grid acts as a root panel for the page that defines two rows:
          * Row 0 contains the back button and page title
          * Row 1 contains the rest of the page layout
      --&gt;
      &lt;Grid
          Style="{StaticResource LayoutRootStyle}"
          DataContext="{Binding Group}"
          d:DataContext="{Binding AllGroups[0], Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"&gt;
  
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="140"/&gt;
              &lt;RowDefinition Height="*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;!--
              The remainder of the page is one large FlipView that displays details for
              one item at a time, allowing the user to flip through all items in the chosen
              group
          --&gt;
  
  
          &lt;!-- Back button and page title --&gt;
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="Auto"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/&gt;
              &lt;TextBlock x:Name="pageTitle" Text="{Binding frontText}" Style="{StaticResource PageHeaderTextStyle}" Grid.Column="1" IsHitTestVisible="false"/&gt;
          &lt;/Grid&gt;
          &lt;FlipView x:Name="flipView" HorizontalAlignment="Left" Margin="0,0,0,0" Grid.Row="1" VerticalAlignment="Top" Width="1356"/&gt;
  
          &lt;VisualStateManager.VisualStateGroups&gt;
  
              &lt;!-- Visual states reflect the application's view state --&gt;
              &lt;VisualStateGroup x:Name="ApplicationViewStates"&gt;
                  &lt;VisualState x:Name="FullScreenLandscape"/&gt;
                  &lt;VisualState x:Name="Filled"/&gt;
  
                  &lt;!-- The back button respects the narrower 100-pixel margin convention for portrait --&gt;
                  &lt;VisualState x:Name="FullScreenPortrait"&gt;
                      &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/VisualState&gt;
  
                  &lt;!-- The back button and title have different styles when snapped --&gt;
                  &lt;VisualState x:Name="Snapped"&gt;
                      &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/VisualState&gt;
              &lt;/VisualStateGroup&gt;
          &lt;/VisualStateManager.VisualStateGroups&gt;
      &lt;/Grid&gt;
  &lt;/common:LayoutAwarePage&gt;
  </code></pre>
  
  <p>My main page's xaml and cs are as follows:</p>
  
  <p>GroupedItemPage.xaml.cs
      using FlashcardBuddy.Data;</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using Windows.Foundation;
  using Windows.Foundation.Collections;
  using Windows.UI.Xaml;
  using Windows.UI.Xaml.Controls;
  using Windows.UI.Xaml.Controls.Primitives;
  using Windows.UI.Xaml.Data;
  using Windows.UI.Xaml.Input;
  using Windows.UI.Xaml.Media;
  using Windows.UI.Xaml.Navigation;
  
  // The Grouped Items Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234231
  
  namespace FlashcardBuddy
  {
      /// &lt;summary&gt;
      /// A page that displays a grouped collection of items.
      /// &lt;/summary&gt;
      public sealed partial class GroupedItemsPage : FlashcardBuddy.Common.LayoutAwarePage
      {
          public GroupedItemsPage()
          {
              this.InitializeComponent();
          }
  
          /// &lt;summary&gt;
          /// Populates the page with content passed during navigation.  Any saved state is also
          /// provided when recreating a page from a prior session.
          /// &lt;/summary&gt;
          /// &lt;param name="navigationParameter"&gt;The parameter value passed to
          /// &lt;see cref="Frame.Navigate(Type, Object)"/&gt; when this page was initially requested.
          /// &lt;/param&gt;
          /// &lt;param name="pageState"&gt;A dictionary of state preserved by this page during an earlier
          /// session.  This will be null the first time a page is visited.&lt;/param&gt;
          protected override void LoadState(Object navigationParameter, Dictionary&lt;String, Object&gt; pageState)
          {
              // TODO: Create an appropriate data model for your problem domain to replace the sample data
              var sampleDataGroups = SampleDataSource.GetGroups((String)navigationParameter);
              this.DefaultViewModel["Groups"] = sampleDataGroups;
          }
  
          /// &lt;summary&gt;
          /// Invoked when an item within a group is clicked.
          /// &lt;/summary&gt;
          /// &lt;param name="sender"&gt;The GridView (or ListView when the application is snapped)
          /// displaying the item clicked.&lt;/param&gt;
          /// &lt;param name="e"&gt;Event data that describes the item clicked.&lt;/param&gt;
          void ItemView_ItemClick(object sender, ItemClickEventArgs e)
          {
              // Navigate to the appropriate destination page, configuring the new page
              // by passing required information as a navigation parameter
              var itemId = ((Deck)e.ClickedItem).id;
              this.Frame.Navigate(typeof(ItemDetailPage), itemId);
          }
  
          private void itemGridView_SelectionChanged(object sender, SelectionChangedEventArgs e)
          {
  
          }
      }
  }
  </code></pre>
  
  <p>GroupedItemPage.xaml
      </p>
  
  <pre><code>    &lt;Page.Resources&gt;
  
          &lt;!--
              Collection of grouped items displayed by this page, bound to a subset
              of the complete item list because items in groups cannot be virtualized
          --&gt;
          &lt;CollectionViewSource
              x:Name="groupedItemsViewSource"
              Source="{Binding Groups}"
              IsSourceGrouped="true"
              ItemsPath="TopItems"
              d:Source="{Binding AllGroups, Source={d:DesignInstance Type=data:SampleDataSource, IsDesignTimeCreatable=True}}"/&gt;
      &lt;/Page.Resources&gt;
  
      &lt;!--
          This grid acts as a root panel for the page that defines two rows:
          * Row 0 contains the back button and page title
          * Row 1 contains the rest of the page layout
      --&gt;
      &lt;Grid Style="{StaticResource LayoutRootStyle}"&gt;
          &lt;Grid.RowDefinitions&gt;
              &lt;RowDefinition Height="140"/&gt;
              &lt;RowDefinition Height="*"/&gt;
          &lt;/Grid.RowDefinitions&gt;
  
          &lt;!-- Horizontal scrolling grid used in most view states --&gt;
          &lt;GridView
              x:Name="itemGridView"
              AutomationProperties.AutomationId="ItemGridView"
              AutomationProperties.Name="Grouped Items"
              Grid.RowSpan="2"
              Padding="116,137,40,46"
              ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
              ItemTemplate="{StaticResource CustomDeckTempate}"
              SelectionMode="None"
              IsSwipeEnabled="false"
              IsItemClickEnabled="True"
              ItemClick="ItemView_ItemClick" SelectionChanged="itemGridView_SelectionChanged" Margin="0,10,0,-10"&gt;
  
              &lt;GridView.ItemsPanel&gt;
                  &lt;ItemsPanelTemplate&gt;                        
                      &lt;VirtualizingStackPanel Orientation="Horizontal"/&gt;
                  &lt;/ItemsPanelTemplate&gt;
              &lt;/GridView.ItemsPanel&gt;
              &lt;GridView.GroupStyle&gt;
                  &lt;GroupStyle&gt;
                      &lt;GroupStyle.HeaderTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Grid Margin="1,0,0,6"&gt;
                                  &lt;TextBlock
                                      AutomationProperties.Name="Group Title"
                                      Style="{StaticResource TextPrimaryGroupStyle}" 
                                      Text="{Binding frontText}" FontFamily="Global User Interface" FontSize="30"/&gt;
                              &lt;/Grid&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/GroupStyle.HeaderTemplate&gt;
                      &lt;GroupStyle.Panel&gt;
                          &lt;ItemsPanelTemplate&gt;
                              &lt;VariableSizedWrapGrid Orientation="Vertical" Margin="0,0,80,0"/&gt;
                          &lt;/ItemsPanelTemplate&gt;
                      &lt;/GroupStyle.Panel&gt;
                  &lt;/GroupStyle&gt;
              &lt;/GridView.GroupStyle&gt;
          &lt;/GridView&gt;
  
          &lt;!-- Vertical scrolling list only used when snapped --&gt;
          &lt;ListView
              x:Name="itemListView"
              AutomationProperties.AutomationId="ItemListView"
              AutomationProperties.Name="Grouped Items"
              Grid.Row="1"
              Visibility="Collapsed"
              Margin="0,-10,0,0"
              Padding="10,0,0,60"
              ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
              ItemTemplate="{StaticResource Standard80ItemTemplate}"
              SelectionMode="None"
              IsSwipeEnabled="false"
              IsItemClickEnabled="True"
              ItemClick="ItemView_ItemClick"&gt;
  
              &lt;ListView.GroupStyle&gt;
                  &lt;GroupStyle&gt;
                      &lt;GroupStyle.HeaderTemplate&gt;
                          &lt;DataTemplate&gt;
                              &lt;Grid Margin="7,7,0,0"&gt;
                                  &lt;Button
                                      AutomationProperties.Name="Group Title"
                                      Style="{StaticResource TextPrimaryButtonStyle}"&gt;
                                      &lt;StackPanel Orientation="Horizontal"&gt;
                                          &lt;TextBlock Text="{Binding frontText}" Margin="3,-7,10,10" Style="{StaticResource GroupHeaderTextStyle}" /&gt;
                                          &lt;TextBlock Text="{StaticResource ChevronGlyph}" FontFamily="Segoe UI Symbol" Margin="0,-7,0,10" Style="{StaticResource GroupHeaderTextStyle}"/&gt;
                                      &lt;/StackPanel&gt;
                                  &lt;/Button&gt;
                              &lt;/Grid&gt;
                          &lt;/DataTemplate&gt;
                      &lt;/GroupStyle.HeaderTemplate&gt;
                  &lt;/GroupStyle&gt;
              &lt;/ListView.GroupStyle&gt;
          &lt;/ListView&gt;
  
          &lt;!-- Back button and page title --&gt;
          &lt;Grid&gt;
              &lt;Grid.ColumnDefinitions&gt;
                  &lt;ColumnDefinition Width="Auto"/&gt;
                  &lt;ColumnDefinition Width="*"/&gt;
              &lt;/Grid.ColumnDefinitions&gt;
              &lt;Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/&gt;
              &lt;TextBlock x:Name="pageTitle" Text="{StaticResource AppName}" Grid.Column="1" IsHitTestVisible="false" Style="{StaticResource PageHeaderTextStyle}"/&gt;
          &lt;/Grid&gt;
  
          &lt;VisualStateManager.VisualStateGroups&gt;
  
              &lt;!-- Visual states reflect the application's view state --&gt;
              &lt;VisualStateGroup x:Name="ApplicationViewStates"&gt;
                  &lt;VisualState x:Name="FullScreenLandscape"/&gt;
                  &lt;VisualState x:Name="Filled"/&gt;
  
                  &lt;!-- The entire page respects the narrower 100-pixel margin convention for portrait --&gt;
                  &lt;VisualState x:Name="FullScreenPortrait"&gt;
                      &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
  
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Padding"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="96,137,10,56"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/VisualState&gt;
  
                  &lt;!--
                      The back button and title have different styles when snapped, and the list representation is substituted
                      for the grid displayed in all other view states
                  --&gt;
                  &lt;VisualState x:Name="Snapped"&gt;
                      &lt;Storyboard&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
  
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemListView" Storyboard.TargetProperty="Visibility"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Visible"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                          &lt;ObjectAnimationUsingKeyFrames Storyboard.TargetName="itemGridView" Storyboard.TargetProperty="Visibility"&gt;
                              &lt;DiscreteObjectKeyFrame KeyTime="0" Value="Collapsed"/&gt;
                          &lt;/ObjectAnimationUsingKeyFrames&gt;
                      &lt;/Storyboard&gt;
                  &lt;/VisualState&gt;
              &lt;/VisualStateGroup&gt;
          &lt;/VisualStateManager.VisualStateGroups&gt;
      &lt;/Grid&gt;
  &lt;/common:LayoutAwarePage&gt;
  </code></pre>