c# - 如何卡住 WPF DataGrid 的第一列

标签 c# wpf wpfdatagrid freeze freezable

<分区>

我有一个 WPF DataGrid..

我想在水平滚动时卡住 WPF DataGrid 的第一列..

我的代码是:

<DataGrid Name="dgQuestionTemplate" HorizontalAlignment="Left" Grid.Row="1" Width="870" HorizontalScrollBarVisibility="Auto" IsReadOnly="False">

            <DataGrid.Columns>                    
                <DataGridTextColumn Binding="{Binding ExamDate}" Header="Date" IsReadOnly="True" Width="90" />
                <DataGridTextColumn Binding="{Binding ExamName}" Header="Test Name" IsReadOnly="True" Width="195" />
                <DataGridTextColumn Binding="{Binding Batch}" Header="Batch" IsReadOnly="True" Width="100" />
                <DataGridTextColumn Binding="{Binding ExamTime}" Header="    Count Down  [Days: hr: min: sec]"  IsReadOnly="True" Width="*" />
            </DataGrid.Columns>

</DataGrid>

最佳答案

设置 Datagrid 的 FrozenColumnCount = "1"

<DataGrid FrozenColumnCount ="1" Name="dgQuestionTemplate" HorizontalAlignment="Left" Grid.Row="1" Width="870" HorizontalScrollBarVisibility="Auto" IsReadOnly="False">

Frozen columns are columns that are always displayed and cannot be scrolled out of visibility. Frozen columns are always the leftmost columns in display order. You cannot drag frozen columns into the group of unfrozen columns or drag unfrozen columns into the group of frozen columns.

DataGrid.FrozenColumnCount

关于c# - 如何卡住 WPF DataGrid 的第一列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18546559/

相关文章:

c# - "ref"使用实例

c# - 在一个Producer和Multi-Consumer实现中等待所有Consumer都处于waiting状态

c# - 带有 EPPlus 解析问题的 CSV

wpf - 绑定(bind) mui ModernTab wpf mvvm

c# - 导致 xamDataGrid 重新绘制

c# - 使用 DataGrid 在一列中显示多个标题

c# - DataGridTemplateColumn - DoubleClick 时出现异常

c# - 从 WPF 中的 DataGridRow 获取列值

c# - 在 Java 中使用需要自定义 SOAP header 的 .NET Web 服务

c# - 嵌套数据网格工作