Note that there are some explanatory texts on larger screens.

plurals
  1. POWP7 Tombstoning - Easy practice
    text
    copied!<p>I have a databound xml reader. MainPage is connected to DetailsPage: When user clicks on the name in Main Page, She gets the details of this name (Age, Gender, Date of Birth etc.) in the DetailsPage.</p> <p>I am in trouble with tombstoning atm. When I click on windows button, then click on back button I get into an empty DetailsPage.</p> <p>What would be the easiest way to solve this problem? I tried to use TombstoneHelper but it also shows empty page.</p> <p>DetailsPage.xaml </p> <pre><code> &lt;controls:PanoramaItem Header="" Margin="0,0,0,80"&gt; &lt;ScrollViewer&gt; &lt;StackPanel&gt; &lt;TextBlock TextWrapping="Wrap" Width="432" Style="{StaticResource PhoneTextExtraLargeStyle}" Margin="0,0,0,10" d:LayoutOverrides="Width" Foreground="#DEFFFFFF"&gt;&lt;Run Text="Personal D"/&gt;&lt;Run Text="e"/&gt;&lt;Run Text="tails"/&gt;&lt;/TextBlock&gt; &lt;StackPanel HorizontalAlignment="Left" Width="432" Orientation="Horizontal"&gt; &lt;TextBlock TextWrapping="Wrap" Margin="20,0,7,0" Foreground="#DEFFFFFF"&gt;&lt;Run Text="Name"/&gt;&lt;Run Text=":"/&gt;&lt;/TextBlock&gt; &lt;TextBlock x:Name="username" TextWrapping="Wrap" Text="{Binding Name}" Foreground="#DEFFFFFF" /&gt; &lt;/StackPanel&gt; &lt;StackPanel HorizontalAlignment="Left" Width="432" Orientation="Horizontal"&gt; &lt;TextBlock TextWrapping="Wrap" Margin="20,0,7,0" Foreground="#DEFFFFFF"&gt;&lt;Run Text="Age"/&gt;&lt;Run Text=":"/&gt;&lt;/TextBlock&gt; &lt;TextBlock x:Name="age" TextWrapping="Wrap" Text="{Binding Age}" Foreground="#DEFFFFFF"/&gt; &lt;/StackPanel&gt; &lt;StackPanel HorizontalAlignment="Left" Width="432" Orientation="Horizontal"&gt; &lt;TextBlock TextWrapping="Wrap" Margin="20,0,7,0" Foreground="#DEFFFFFF"&gt;&lt;Run Text="Nationality"/&gt;&lt;Run Text=":"/&gt;&lt;/TextBlock&gt; &lt;TextBlock x:Name="country" TextWrapping="Wrap" Text="{Binding Country}" Foreground="#DEFFFFFF"/&gt; &lt;/StackPanel&gt; &lt;StackPanel HorizontalAlignment="Left" Width="432" Orientation="Horizontal"&gt; &lt;TextBlock TextWrapping="Wrap" Margin="20,0,7,0" Foreground="#DEFFFFFF"&gt;&lt;Run Text="Country of Birth"/&gt;&lt;Run Text=":"/&gt;&lt;/TextBlock&gt; &lt;TextBlock x:Name="cobirth" TextWrapping="Wrap" Text="{Binding Cobirth}" Foreground="#DEFFFFFF"/&gt; &lt;/StackPanel&gt; &lt;StackPanel HorizontalAlignment="Left" Width="432" Orientation="Horizontal"&gt; &lt;TextBlock TextWrapping="Wrap" Margin="20,0,7,0" Foreground="#DEFFFFFF"&gt;&lt;Run Text="Place of Birth"/&gt;&lt;Run Text=":"/&gt;&lt;/TextBlock&gt; &lt;TextBlock x:Name="fobirth" TextWrapping="Wrap" Text="{Binding Pobirth}" Foreground="#DEFFFFFF"/&gt; &lt;/StackPanel&gt; &lt;/StackPanel&gt; &lt;/ScrollViewer&gt; &lt;/controls:PanoramaItem&gt; </code></pre> <p>DetailsPage.cs </p> <p>using TombstoneHelper;</p> <pre><code> public User() { InitializeComponent(); SupportedOrientations = SupportedPageOrientation.Portrait; } protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedFrom(e); this.SaveState(); // &lt;- first line } protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); this.RestoreState(); // &lt;- second line } </code></pre> <p>Mainpage.Cs</p> <pre><code> private void UserListBox_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (e.AddedItems.Count &gt; 0) { NavigationService.Navigate(new Uri("/DetailsPage.xaml", UriKind.Relative)); FrameworkElement root = Application.Current.RootVisual as FrameworkElement; root.DataContext = (RosterItem)e.AddedItems[0]; ((ListBox)sender).SelectedIndex = -1; } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload