wpf ListView 滚动条样式

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20652709/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 10:15:01  来源:igfitidea点击:

ListView Scrollbar Styling

wpflistviewscrollbar

提问by androider

I am working on a WPF project. I need to customize the horizontal scrollbar of Listview,like reducing its height,changing background etc. How do I achieve this?

我正在做一个 WPF 项目。我需要自定义 Listview 的水平滚动条,例如降低其高度、更改背景等。我该如何实现?

Using this, doesn't seem to have any effect:

使用这个,似乎没有任何效果:

 <ListView>
     <ListView.Resources>
         <Style TargetType="ScrollBar">
                <Setter Property="Height" Value="10"/>
         </Style>
     </ListView.Resources>
 </ListView>

采纳答案by jnovo

If you want to modify the width and height of the bars, you can take a look at this question, which points you in the direction of using System.Windows.SystemParametersto modify those values.

如果你想修改条形的宽度和高度,你可以看看这个问题,它为你指明了使用System.Windows.SystemParameters修改这些值的方向。

However I think you require more complex styling (e.g. change the background) so I'm afraid you will need to play with control template parts. Check these two links (found in the answer to this question):

但是我认为您需要更复杂的样式(例如更改背景),所以恐怕您需要使用控制模板部件。检查这两个链接(在这个问题的答案中找到):