WPF DataGrid - 刷新后保持滚动位置

时间:2022-07-06 09:05:53

Anyone knows how to maintain the vertical scroll position after the Refresh command?

任何人都知道如何在刷新命令后保持垂直滚动位置?

My Datagrid receives binding from a List of objects.

我的Datagrid从对象列表接收绑定。

Many thanks, and sorry for my english.

非常感谢,对不起我的英语。

1 个解决方案

#1


0  

2 posible solutions :

2个可行的解决方案:

1) Try to update the list instead of replacing it. it means adding new items and removing items you don't need.

1)尝试更新列表而不是替换它。它意味着添加新项目并删除您不需要的项目。

2) you can save the state of the scroller before refreshing and then scroll programmly to the selected item.

2)您可以在刷新之前保存滚动条的状态,然后将程序滚动到所选项目。

WPF Toolkit: how to scroll datagrid to show selected item from code behind?

WPF工具包:如何​​滚动数据网格以从后面的代码中显示所选项目?

#1


0  

2 posible solutions :

2个可行的解决方案:

1) Try to update the list instead of replacing it. it means adding new items and removing items you don't need.

1)尝试更新列表而不是替换它。它意味着添加新项目并删除您不需要的项目。

2) you can save the state of the scroller before refreshing and then scroll programmly to the selected item.

2)您可以在刷新之前保存滚动条的状态,然后将程序滚动到所选项目。

WPF Toolkit: how to scroll datagrid to show selected item from code behind?

WPF工具包:如何​​滚动数据网格以从后面的代码中显示所选项目?