below is my datagrid's definition:
下面是我的datagrid的定义:
<DataGrid
Name="ODataGrid"
AutoGenerateColumns="False"
Grid.Row="0"
Grid.Column="0"
CanUserAddRows="False"
AlternationCount="2"
HeadersVisibility="All"
IsReadOnly="True"
SelectionUnit="FullRow"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Background="#EBF0F0"
AlternatingRowBackground="#E9E8EF"
HorizontalGridLinesBrush="#7F7F7F"
VerticalGridLinesBrush="#7F7F7F"
SelectedItem="{Binding vmItem}"
CellStyle="{StaticResource ODataGridCellStyle}"
ItemsSource="{Binding vmResults}"
Tag="{Binding DataContext, ElementName=BaseGrid}">
Below are the steps I took to get the error.
以下是我为获取错误而采取的步骤。
- The first row was selected by default.
- 默认选择第一行。
- I select another row in the datagrid.
- 我在datagrid中选择另一行。
- I do a sort by clicking on one of the column header.
- 我点击其中一个列标题进行排序。
- I do a scroll by dragging the vertical scroll bar.
- 我通过拖动垂直滚动条来滚动。
- The initial first row was somehow auto selected.
- 最初的第一行以某种方式自动选择。
- So now, there are 2 rows being selected.
- 所以现在,有两行被选中。
Why this behaviour? Anyway to prevent the auto select on scroll? Thanks.
为什么会这样?无论如何要阻止自动选择滚动?谢谢。
2 个解决方案
#1
0
EnableRowVirtualization="False"
In the datagrid properties.
在datagrid属性中。
#2
-2
add this property in datagrid
在datagrid中添加此属性
VirtualizingStackPanel.IsVirtualizing="False"
#1
0
EnableRowVirtualization="False"
In the datagrid properties.
在datagrid属性中。
#2
-2
add this property in datagrid
在datagrid中添加此属性
VirtualizingStackPanel.IsVirtualizing="False"