C# 如何仅为DataGrid中的列子集实现水平滚动条?
示例:我们有很多列,只想水平滚动第二列直到最后一列C# 如何仅为DataGrid中的列子集实现水平滚动条?,c#,wpf,datagrid,C#,Wpf,Datagrid,示例:我们有很多列,只想水平滚动第二列直到最后一列 | Name | Mail | Status | Location | ... many other columns ... | Jon | ... | ... | ... | ... | Name | Mail | Status | Location | ... many other columns ... | Jon | ... | ... | ... | ... |<---
| Name | Mail | Status | Location | ... many other columns ...
| Jon | ... | ... | ... | ...
| Name | Mail | Status | Location | ... many other columns ...
| Jon | ... | ... | ... | ...
|<--- scrollbar here --->|
现在,我们希望“修复”列Name
,并有一个水平滚动条,以列Mail
开始,最后一列结束
| Name | Mail | Status | Location | ... many other columns ...
| Jon | ... | ... | ... | ...
| Name | Mail | Status | Location | ... many other columns ...
| Jon | ... | ... | ... | ...
|<--- scrollbar here --->|
|姓名|邮件|状态|位置|。。。许多其他专栏。。。
|乔恩。。。
||
是否可以用WPF实现这样的行为?您应该能够使用
DataGrid
的属性指定从左侧开始要“冻结”的列数
但是,如果要冻结不是最左边的任何其他列,则可能需要实现自定义行为。:) 我知道在DataGrid的WPF工具包版本中有冻结列的功能,但我不确定它是否在MSDN的DataGrid中实现。google快速搜索“WPF DataGrid冻结列”返回,但我不确定该问题是否特定于DataGrid的WPF工具包版本(该属性在WPF工具包中可用)。如果MSDN的
DataGrid
中不存在这种情况,您可能需要实现一些自定义行为。@Rachel Perfect!我缺少关键字冻结,无法开始适当的搜索。在MSDN的DataGrid中,仍然有属性FrozenColumnCount,它修复了前n列并支持滚动最后一列。正是我想要的。非常感谢!(如果您将此作为答案发布,您将收到我的接受支票)当然,它作为答案发布:)我最初没有发布它,因为我不知道这是否是DataGrid上的有效属性。