with XAML (WinUI3) GridView and SelectionMode="Extended", how from c++ code (or even CS) can I deselect items that the user clicked.

Mart Goodall 20 Reputation points
2023-09-17T23:26:45.4366667+00:00

SelectionMode="Extended" allows many items to be clicked at once. after clicking, multiple items can be drag/dropped onto a target. Once this happens, I need, via C++ code, to deselect certain items that were clicked. what is the way to perform the deselect of individual items, or even deselect of all items. Currently they remain selected until the user manually clicks each one again to toggle the selection off.

Windows App SDK
Windows App SDK
A set of Microsoft open-source libraries, frameworks, components, and tools to be used in apps to access Windows platform functionality on many versions of Windows. Previously known as Project Reunion.
737 questions
C++
C++
A high-level, general-purpose programming language, created as an extension of the C programming language, that has object-oriented, generic, and functional features in addition to facilities for low-level memory manipulation.
3,591 questions
XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
778 questions
0 comments No comments
{count} votes

Accepted answer
  1. Xiaopo Yang - MSFT 11,746 Reputation points Microsoft Vendor
    2023-09-18T01:58:02.7+00:00

    According to Extended selection,

    The SelectedIndex, SelectedItem, and SelectedItems properties are synchronized. For example, if you set SelectedIndex to -1, SelectedItem is set to null and SelectedItems is empty. And if you set SelectedItem to null, SelectedIndex is set to -1 and SelectedItems is empty. In multi-select mode, SelectedItem contains the item that was selected first, and Selectedindex contains the index of the item that was selected first.

    Or you can use the ListViewBase.DeselectRange(ItemIndexRange) Method.


0 additional answers

Sort by: Most helpful