WPF:如何冻结数据网格中的列标题 [英] WPF: How to freeze column header in datagrid

查看:68
本文介绍了WPF:如何冻结数据网格中的列标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在我的 WPF 窗口的 DataGrid 中冻结我的列标题,以便向下滚动时,标题仍然可见.

How can I freeze my column header in a DataGrid in my WPF Window so that when I scroll down, the header is still visible.

[编辑]

这是我的 XAML:

<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Visible">
    <DataGrid Name="ModelsGrid" Background="Transparent" Foreground="Black"  RowHeight="30" ColumnWidth="100"  AutoGenerateColumns="False" ItemsSource="{Binding}">
        <DataGrid.Columns>
            <DataGridTextColumn Header="Property ID" Binding="{Binding Path=Id}" />
            <DataGridTextColumn Header="Name" Width="Auto" Binding="{Binding Path=PropertyName}" />
            <DataGridTextColumn Header="Description" Width="Auto" Binding="{Binding Path=Description}" />
            <DataGridTextColumn Header="Access" Width="Auto" Binding="{Binding Path=Accessibility}" />
            <DataGridTextColumn Header="Type" Width="Auto" Binding="{Binding Path=Type}" />
            <DataGridTextColumn Header="Category" Width="Auto" Binding="{Binding Path=Category}" />
        </DataGrid.Columns>
    </DataGrid>
</ScrollViewer>

[编辑]

我只需要去掉 ScrollViewer 就解决了.

I just had to get rid of the ScrollViewer and it's solved.

推荐答案

我只需要去掉 ScrollViewer 就解决了.

I just had to get rid of the ScrollViewer and it's solved.

这篇关于WPF:如何冻结数据网格中的列标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆