Reputation: 1636
I use a CollectionView
control to display a list of files, if users click an item a popup appears displaying information about the file and a button to download it, the problem is that I use the SelectionChanged
method of the CollectionView
to run this action, but if users close the popup and click again on the same item nothing happens. Back when we use ListView
control, the ItemTapped
event runs every time the users click the same item, but i need to changed to CollectionView
because later we'll change the file item from a single row to multiple columns (2 or 3).
It is possible to make the users click on the same item multiple times with CollectionView
control ?
P.D: also try to set the SelectedItem
to null but the app crashes if the users select again the same item.
Upvotes: 0
Views: 1723
Reputation: 15001
It works for me when i set SelectedItem
to null
.What else did you do when you set selectitem?
below is my simple sample,i use DisplayAlert instead of popup.
the xaml :
<CollectionView x:Name="collection" SelectionChanged="CollectionView_SelectionChanged" SelectionMode="Single" >
<CollectionView.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>Baboon</x:String>
<x:String>Capuchin Monkey</x:String>
<x:String>Blue Monkey</x:String>
<x:String>Squirrel Monkey</x:String>
<x:String>Golden Lion Tamarin</x:String>
<x:String>Howler Monkey</x:String>
<x:String>Japanese Macaque</x:String>
</x:Array>
</CollectionView.ItemsSource>
</CollectionView>
in page xaml.cs:
private async void CollectionView_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
if (collection.SelectedItem != null)
{
await DisplayAlert("Question?", "Would you like to play a game", "Yes", "No");
collection.SelectedItem = null;
}
}
the effect is like below:
Upvotes: 1