title: Xamarin - clearing ListView selection
body: <p>I am actually working with this piece of code</p>
  
  <pre><code>using System;
  using Xamarin.Forms;
  using System.Diagnostics;
  
  namespace CryptoUI
  {
      public class HomePage : Xamarin.Forms.MasterDetailPage
      {
          public HomePage()
          {
          // Set up the Master, i.e. the Menu
              Label header = new Label
              {
                  Text = "MENU",
                  Font = Font.SystemFontOfSize(20, FontAttributes.Bold),
                  HorizontalOptions = LayoutOptions.Center
              };
          // create an array of the Page names
          string[] myPageNames = {
              "Main",
              "Page 2",
              "Page 3",
          };
  
          // Create ListView for the Master page.
          ListView listView = new ListView
          {
              ItemsSource = myPageNames,
          };
  
          // The Master page is actually the Menu page for us
          this.Master = new ContentPage
          {
              Title = "Test",
              Content = new StackLayout
              {
                  Children = 
                  {
                      header, 
                      listView
                  },
              }
          };
  
          // Define a selected handler for the ListView contained in the Master (ie Menu) Page.
          listView.ItemSelected += (sender, args) =&gt;
          {
              // Set the BindingContext of the detail page.
              this.Detail.BindingContext = args.SelectedItem;
  
              string currentPage = this.GetType().Name.ToString();
  
              // This is where you would put your “go to one of the selected pages”
              if(listView.SelectedItem.Equals("Main") &amp;&amp; !currentPage.Equals("HomePage")){
                  AsyncPush(new HomePage());
              }
              else if(listView.SelectedItem.Equals("Page 2") &amp;&amp; !currentPage.Equals("SecondPage")){
                  AsyncPush(new SecondPage());
              }
              else if(listView.SelectedItem.Equals("Page 3") &amp;&amp; !currentPage.Equals("ThirdPage")){
                  AsyncPush(new ThirdPage());
              }               
  
              // Show the detail page.
              this.IsPresented = false;
          };
              listView.ItemSelected += (senders, e) =&gt; {
                  if (e.SelectedItem == null) return; // don't do anything if we just de-selected the row
                  // do something with e.SelectedItem
                  ((ListView)senders).SelectedItem = null; // de-select the row
              };
  
          // Set up the Detail, i.e the Home or Main page.
          Label myHomeHeader = new Label
          {
              Text = "Home Page",
              HorizontalOptions = LayoutOptions.Center
          };
  
          string[] homePageItems = { "Alpha", "Beta", "Gamma" };
          ListView myHomeView = new ListView {
              ItemsSource = homePageItems,
          };
  
          var myHomePage = new ContentPage();
  
          myHomePage.Content = new StackLayout
          {
              Children = 
              {
                  myHomeHeader, 
                  myHomeView
              } ,
          };
          this.Detail = myHomePage;
      }
  
          public async void AsyncPush(Page page)
          {
              await Navigation.PushAsync(page);
          }
      }
  }
  </code></pre>
  
  <p>This code actually shows an easy FlyOut menu, using the Xamarin Forms technologies.
  I am currently trying to understand how I could easily clear the ListView selection after I have selected which page I want to head to!</p>
  
  <p>I found this piece of code on Xamarin's website for devs (<a href="http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/listview/" rel="noreferrer">http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/listview/</a>);</p>
  
  <pre><code>listView.ItemSelected += (sender, e) =&gt; {
      if (e.SelectedItem == null) return; // don't do anything if we just de-selected the row
      // do something with e.SelectedItem
      ((ListView)sender).SelectedItem = null; // de-select the row
  };
  </code></pre>
  
  <p>But I can't currently figure out how I should integrate it with my code above there :)</p>