title: How to disable default selection in a ListView?
body: <p>On a detail page, I have a listview and a control that shows the details according to the selected item in the listview. On the main page, there are several items shown of this collection (which are again shown in the detail page). If the user clicks one of them, it navigates to the detail page and shows the details. Unfortunately, every time a user clicks an item on the main page, the selection-changed event gets raised two times: Once for the first item (default item) and one for the selected item. How can I correctly handle this? - I only need the second (real) event.</p>
  
  <p>I found this <a href="https://stackoverflow.com/questions/11388768/how-to-disable-the-default-selection-in-listview-when-you-navigate-to-it">post</a>, but couldn't solve my problem...</p>
  
  <p>This is my code (shortened):</p>
  
  <p>MainPage.xaml:</p>
  
  <pre><code>&lt;GridView
      x:Name="itemGridView"
      ItemsSource="{Binding Source={StaticResource groupedItemsViewSource}}"
      ItemTemplate="{StaticResource Custom250x250ItemTemplate}"
      SelectionMode="None"
      IsItemClickEnabled="True"
      ItemClick="ItemView_ItemClick"&gt;
  
      &lt;!-- details --&gt;
  
   &lt;/GridView&gt;
  </code></pre>
  
  <p>MainPage.xaml.cs:</p>
  
  <pre><code> 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 = ((ArticleDataItem)e.ClickedItem).Id;
      this.Frame.Navigate(typeof(ItemDetailPage), itemId);
   }
  </code></pre>
  
  <p>ItemDetailPage.xaml:</p>
  
  <pre><code> &lt;ListView
      x:Name="itemListView"
      ItemsSource="{Binding Source={StaticResource itemsViewSource}}"
      IsSwipeEnabled="False"
      SelectionChanged="ItemListView_SelectionChanged"
      ItemTemplate="{StaticResource Standard130ItemTemplate}" 
      ItemContainerStyle="{StaticResource CustomListViewItemStyle}" 
      /&gt;
  
   &lt;!-- ... --&gt;
  
   &lt;WebView x:Name="contentBrowser" /&gt;
  </code></pre>
  
  <p>ItemDetailPage.xaml.cs:</p>
  
  <pre><code> void ItemListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
   {
      // this event gets raised two times when navigating from the MainPage to this page !!!
  
      // Invalidate the view state when logical page navigation is in effect, as a change
      // in selection may cause a corresponding change in the current logical page.  When
      // an item is selected this has the effect of changing from displaying the item list
      // to showing the selected item's details.  When the selection is cleared this has the
      // opposite effect.
      if (this.UsingLogicalPageNavigation()) this.InvalidateVisualState();
  
      if (itemsViewSource.View.CurrentItem == null)
      {
           return;
      }
  
      // reset contentBrowser-Content 
      contentBrowser.NavigateToString(Tasks.WebViewPreCode + "&lt;p&gt;Loading...&lt;/p&gt;" + Tasks.WebViewAfterCode);
  
      var selectedItem = (ArticleDataItem)this.itemsViewSource.View.CurrentItem;
  
      if ( selectedItem == null )
      {
           contentBrowser.NavigateToString(Tasks.WebViewPreCode + "&lt;p&gt;There was an error. Please try again later.&lt;/p&gt;" + Tasks.WebViewAfterCode);
          return;
      }
  
      // Download item details
      ArticleDataSource.ReadArticle(selectedItem); // this really shouldn't be called two times
  
  }
  </code></pre>
  
  <p>thank you for your help!</p>