DEV Community

David Ortinau for .NET

Posted on

1

CollectionView: Clearing Selection

CollectionView supports single and multiple item selection modes. Sometimes after selecting items, the user may want to clear all selections and start afresh, or you may want to reset after an action has been taken. This is super easy!

async void ClearItem_Clicked(System.Object sender, System.EventArgs e)
{
PhotosCV.SelectedItems.Clear();
}
view raw snippet.cs hosted with ❤ by GitHub

You may instead bind the SelectedItems and SelectedItem to your binding context (e.g. ViewModel) and reset the collection there.

Resources:

GitHub logo davidortinau / Xappy

A mobile app to track Xamarin news and explore all the goodness that is .NET for Mobile developers

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay