WPF:如何冻结的ListView标题行,这样就不会在屏幕上滚过就不、会在、屏幕、上滚

由网友(幼儿园扛把子)分享简介:我新的WPF的发展,我有一个ListView和我想要冻结标题行,这样就不会在屏幕上滚过,当用户滚动列表。XAML中code,我继承,看起来是这样的:<的ScrollViewer Horizo​​ntalScrollBarVisibility =自动VerticalScrollBarVisibility =自动&...

我新的WPF的发展,我有一个ListView和我想要冻结标题行,这样就不会在屏幕上滚过,当用户滚动列表。 XAML中code,我继承,看起来是这样的:

 <的ScrollViewer Horizo​​ntalScrollBarVisibility =自动VerticalScrollBarVisibility =自动>
  < D​​ockPanel中>
    <形式:BindableGrid DockPanel.Dock =评出的[code剪断] GT;
    < ListView.View>
      < GridView控件>
        < GridViewColumn标题=可乐DisplayMemberBinding ={结合可乐}/>
        < GridViewColumn标题=COLBDisplayMemberBinding ={结合COLB}/>
           [等等]
 

解决方案

的ListView 已经这样做了 - 它有一个内部的的ScrollViewer ,只有滚动的物品,而不是头。

问题是,你的外的ScrollViewer 告诉其子(即 DockPanel中),它有可用的无限空间,和 DockPanel中讲述了这样它的孩子们,让你的的ListView 最终占据尽可能多的空间,因为它需要显示所有项目和内部的ScrollViewer 不出来。

如果你拿走你的外的ScrollViewer 的ListView 应该拿起它的空间有限,而内部的ScrollViewer 将会出现。

WPF引入 导入 库

这显然会影响在剩下的东西你的 DockPanel中,所以我想看看会发生什么,并从那里走了。

I am new to WPF development, I have a ListView and I want to freeze the header row so that it won't scroll off the screen when the user scrolls the list. The xaml code, I have inherited, looks something like this:

<ScrollViewer HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
  <DockPanel>
    <forms:BindableGrid DockPanel.Dock="Top" [code snipped] >
    <ListView.View>
      <GridView>
        <GridViewColumn Header="ColA" DisplayMemberBinding="{Binding ColA}" />
        <GridViewColumn Header="ColB" DisplayMemberBinding="{Binding ColB}" />
           [etc]

解决方案

The ListView already does this - it has an internal ScrollViewer that only scrolls the items and not the header.

The issue is that your outer ScrollViewer tells its child (the DockPanel) that it has infinite space available, and the DockPanel tells this to its children, so your ListView ends up taking up as much space as it needs to display all the items and the internal ScrollViewer doesn't show up.

If you take away your outer ScrollViewer, the ListView should pick up that it has limited space, and the internal ScrollViewer will appear.

This will obviously affect the rest of the stuff in your DockPanel, so I'd see what happens and go from there.

阅读全文

相关推荐

最新文章