Note that there are some explanatory texts on larger screens.

plurals
  1. POMisbehaviour in LoadState using SplitPage
    text
    copied!<p>I am working on a Windows 8 Metro Newsreader-App (with C# and XAML). I show the feed-items on a <code>Grouped Items Page</code> (template). A click forwards the user to a detail-page, which I implemented as a <code>Split Page</code>. Therefore, I have an Image-Gallery where the user can navigate from this DetailPage (and back). This works fine. On the ItemDetailPage I have to assign the Data in the <code>LoadState</code> function. The template offers me the following solution:</p> <pre><code>protected override void LoadState(Object navigationParameter, Dictionary&lt;String, Object&gt; pageState) { // TODO: Assign a bindable group to this.DefaultViewModel["Group"] // TODO: Assign a collection of bindable items to this.DefaultViewModel["Items"] if (pageState == null) { // When this is a new page, select the first item automatically unless logical page // navigation is being used (see the logical page navigation #region below.) if (!this.UsingLogicalPageNavigation() &amp;&amp; this.itemsViewSource.View != null) { this.itemsViewSource.View.MoveCurrentToFirst(); } } else { // Restore the previously saved state associated with this page if (pageState.ContainsKey("SelectedItem") &amp;&amp; this.itemsViewSource.View != null) { // TODO: Invoke this.itemsViewSource.View.MoveCurrentTo() with the selected // item as specified by the value of pageState["SelectedItem"] } } } </code></pre> <p>What I did was the following:</p> <pre><code>protected override void LoadState(Object navigationParameter, Dictionary&lt;String, Object&gt; pageState) { if (pageState == null) { // When this is a new page, select the first item automatically unless logical page // navigation is being used (see the logical page navigation #region below.) if (!this.UsingLogicalPageNavigation() &amp;&amp; this.itemsViewSource.View != null) { this.itemsViewSource.View.MoveCurrentToFirst(); } } else { // Restore the previously saved state associated with this page if (pageState.ContainsKey("SelectedItem") &amp;&amp; this.itemsViewSource.View != null) { this.itemsViewSource.View.MoveCurrentTo(pageState["SelectedItem"]); } } var item = ArticleDataSource.GetItem((int)navigationParameter); if (item != null) { this.DefaultViewModel["Group"] = item.Group; this.DefaultViewModel["Items"] = item.Group.Items; if (this.itemsViewSource.View != null) this.itemsViewSource.View.MoveCurrentTo(item); // remove? // Register this page as a share source. this.dataTransferManager = DataTransferManager.GetForCurrentView(); this.dataTransferManager.DataRequested += new TypedEventHandler&lt;DataTransferManager, DataRequestedEventArgs&gt;(this.OnDataRequested); } } </code></pre> <ol> <li>If I navigate from the OverviewPage to the DetailsPage the selected item (A) is shown.</li> <li>I select an other item (from the list) and the correct details (B) are shown.</li> <li>If I navigate from the DetailsPage to the GalleryPage the images of the correct item (B) are shown.</li> <li>If I now navigate back (to the DetailsPage) not the last selected item (B) but the item I selected (A) to enter DetailsPage is shown.</li> </ol> <p>I am aware of the fact that I changed the order (proposed by the template) and I added <code>if (this.itemsViewSource.View != null) this.itemsViewSource.View.MoveCurrentTo(item);</code> that I'd probably better remove.</p> <p>I think that the problem (described in step 4) is, that <code>this.itemsViewSource.View</code> is null and therefore (logically) <code>this.itemsViewSource.View.MoveCurrentTo(pageState["SelectedItem"])</code> doesn't get executed. Unfortunately, I was unable to find out why or if this is the bug.</p> <p>Any help or link to a tutorial (which could solve my problem) are really much appreciated! thanks.</p>
 

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