WPF的ListView没有滚动条,如果高度设置为auto [英] WPF ListView no scrollbar if height set to auto

查看:1369
本文介绍了WPF的ListView没有滚动条,如果高度设置为auto的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我有一个绑定到一个集合一个ListView。我设置的ListView自动的高度,它占用该地区的所有空间。但是没有滚动条后,我将高度设置为自动。如果我给它一个高度,然后滚动条会显示出来。

标记为pretty很像以下

 <网格和GT;
   <&StackPanel的GT;
      <&扩展GT;
          <&DataGrid的GT;
      <&扩展GT;
          <&的ListView GT;


解决方案

我有一种预感,你的的ListView 是面板,允许它不受限制垂直扩大内需。

如果你把一个的ListView 的StackPanel ,例如的ListView 的高度超过该的StackPanel 的高度。在的ListView 增加了其​​高度,以显示其所有项目,就我们关心的,因此没有滚动条。

但是,如果您更改的StackPanel 电网,其中控制自动尝试,以适应自己的区域内中,的ListView 将自动获得一个滚动条时,它包含了更多的项目比它可以显示。

这将可能是最简单地通过调整布局包含的ListView解决

Hi i have a ListView that binds to a collection. I set the height of the ListView to auto for it to take up all the space in the region. However there is not scrollbar after i set the height to auto. If i give it a height then the scrollbar would show up.

the markup is pretty much like the following

<Grid>
   <StackPanel>
      <Expander>
          <DataGrid>
      <Expander>
          <ListView>

解决方案

I have a hunch that your ListView is inside a panel that allows it to expand vertically without limit.

If you put a ListView inside a StackPanel, for example, the ListView's height can exceed the height of the StackPanel. The ListView has increased its height to show all its items, as far as it's concerned, thus no scrollbar.

However, if you change that StackPanel to a Grid, where controls automatically try to fit themselves inside that area, the ListView will automatically have a scrollbar when it contains more items than it can display.

This will probably be solved most simply by adjusting your layout that contains the ListView.

这篇关于WPF的ListView没有滚动条,如果高度设置为auto的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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