[英]WPF Datagrid doesn't deselect hidden items
I have a DataGrid with several items, and my program's logic depends on the selected rows. 我有一个包含多个项目的DataGrid,程序的逻辑取决于所选的行。
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. 我知道使用MouseDown事件来操纵所选项目的解决方案是可行的,但是我想避免这样做。
Edit: I need it to be SelectionMode="Extended". 编辑:我需要它是SelectionMode =“ Extended”。
如果要禁用多选行为,请将SelectionMode
设置为Single
<DataGrid SelectionMode="Single"
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.