Unplanned
Last Updated: 15 Jun 2026 09:01 by ADMIN
Benjamin
Created on: 15 Jun 2026 08:41
Category: CollectionView
Type: Feature Request
0
CollectionView: Provide a single deselect option via keyboard
I want to have a single deselect built-in using keyboard key. 
There is a feature request for single deselect selection mode here: https://feedback.telerik.com/maui/1715480-collectionview-provide-a-single-deselect-option-when-tapping-the-selected-item-again-to-be-deselected 
1 comment
ADMIN
Didi
Posted on: 15 Jun 2026 09:01
Solution on windows:
#if WINDOWS
this.collectionView.HandlerChanged += CollectionView_HandlerChanged;

private void CollectionView_HandlerChanged(object? sender, EventArgs e)
{
    
    if (this.collectionView.Handler?.PlatformView is Microsoft.UI.Xaml.UIElement nativeView)
    {
        nativeView.PreviewKeyDown += NativeView_PreviewKeyDown;
    }
}

private void NativeView_PreviewKeyDown(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e)
{
    if (e.Key == Windows.System.VirtualKey.Space && this.collectionView.SelectedItem != null)
    {
        this.collectionView.SelectedItem = null;
        
        e.Handled = true;
    }
}
#endif

Regards,
Didi
Progress Telerik