WPF ListView ScrollBar 可见到 false
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1561780/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
WPF ListView ScrollBar visible to false
提问by David Brunelle
Is it possible to force the horizontal (or vertical) scroll to NOT display even when needed?
即使需要,是否可以强制水平(或垂直)滚动不显示?
The thing is that I need to display colors that are different depending of the item. That works fine but you can clearly see that the color does not reach both edge of the list view, which is kinda ugly. To make things worse, I have in my listview another listview that contains another list of item. Those item's background does not come even close to the edge of the listview.
问题是我需要根据项目显示不同的颜色。这工作正常,但您可以清楚地看到颜色没有到达列表视图的两个边缘,这有点难看。更糟糕的是,我的列表视图中有另一个包含另一个项目列表的列表视图。这些项目的背景甚至不接近列表视图的边缘。
回答by Guy Starbuck
You can specify the visibility of the scrollbar for both vertical and horizontal scrolling to four options, using the ScrollViewer.HorizontalScrollBarVisibility
and ScrollViewer.VerticalScrollBarVisibility
attached properties: Auto
, Disabled
, Hidden
and Visible
.
您可以指定滚动条的两个垂直和水平滚动的知名度,四个选项,使用ScrollViewer.HorizontalScrollBarVisibility
和ScrollViewer.VerticalScrollBarVisibility
附加属性:Auto
,Disabled
,Hidden
和Visible
。
<ListView ScrollViewer.HorizontalScrollBarVisibility="Disabled">
Disabled
will have it never show up and scrolling is not possible, Hidden
will have it not show, but will allow users to scroll using text selection and arrow keys/mousewheel, etc.
Disabled
将永远不会显示它并且无法滚动,Hidden
让它不显示,但将允许用户使用文本选择和箭头键/鼠标滚轮等滚动。
回答by Carlo
Directly on the scroll bar:
直接在滚动条上:
<ScrollViewer HorizontalScrollBarVisibility="Hidden" />
If you're doing it in a control that implements it in its ControlTemplate:
如果您在一个在其 ControlTemplate 中实现它的控件中执行此操作:
<StackPanel ScrollViewer.HorizontalScrollBarVisibility="Hidden" />