简体   繁体   中英

WPF Datagrid doesn't deselect hidden items

I have a DataGrid with several items, and my program's logic depends on the selected rows.

When I click on a row, the usual behavior is to selected the clicked row and deselect all others. However, if I click on a row, then scroll down to the point it becomes not visible anymore, and then click on another row, it will keep the 2 rows selected.

I know that a solution using MouseDown events to manipulate the selected items would work, but I wanted to prevent doing that.

Edit: I need it to be SelectionMode="Extended".

如果要禁用多选行为,请将SelectionMode设置为Single

<DataGrid SelectionMode="Single"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM