Created
June 27, 2014 03:53
-
-
Save ajonno/6ae0d2aebfae79d2ec9c to your computer and use it in GitHub Desktop.
how to "reset" a selected row in a ListView --->> when using Xamarin.Forms
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
listView.ItemSelected += async (object sender, SelectedItemChangedEventArgs e) => { | |
//Paste this ---v | |
// Prevents .ItemSelected from running again when SelectedItem is set to null on line below | |
if (listView.SelectedItem == null) | |
return; | |
// Sets the SelectedItem so it can be used by the Switch statement below | |
var whichCategory = (Category)e.SelectedItem; | |
// Clears the SelectedItem, this will trigger a 2nd .ItemSelected event which is caught on line above | |
listView.SelectedItem = null; | |
//Console.WriteLine("Clicked"); //just for testing when the .ItemSelected event is being triggered | |
//Paste this--^ | |
switch (whichCategory.Name.ToString()) | |
{ | |
case "item 1": | |
Navigation.PushAsync(new SomePage()); | |
break; | |
case "item 2": | |
Navigation.PushAsync(new SomePage()); | |
break; | |
case "item 3": | |
Navigation.PushAsync(new SomePage()); | |
break; | |
case "item 4": | |
Navigation.PushAsync(new SomePage()); | |
break; | |
case "item 5": | |
Navigation.PushAsync(new SomePage()); | |
break; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment