在 ScrollViewer wpf 中更改 ScrollBar 的背景颜色 [英] Change background color of ScrollBar in ScrollViewer wpf

查看:24
本文介绍了在 ScrollViewer wpf 中更改 ScrollBar 的背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何更改滚动条的背景颜色:

I know how to change the background color of a scrollbar:

<ScrollBar Height="27" Margin="36,96,12,0" Name="scrollBar1" Background="Red"></ScrollBar>

这是我的红色背景图片:

here is the picture with my red background:

我怎么能用 ScrollViewer 做同样的事情?我的 ScrollViewer 中有一个网格,如果我更改 ScrollViewer 的属性,它似乎会更改网格内内容的属性.

How could I do the same thing with ScrollViewer? I have a grid inside my ScrollViewer and if I change the properties of ScrollViewer it seem to change the properties of the content inside my grid.

<ScrollViewer>


    <Grid Name="Parent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
             ....
             ....
             ... etc

产生:

我的网格内容在左侧命名为 Parent.如何在此 ScrollViewer 上放置红色背景?

with the content of my grid named Parent on the left. How could I place a red background on this ScrollViewer?

推荐答案

将 ScrollViewer 样式设置为与您单独构建的样式相同.这里有两个链接,作者首先创建样式,然后将所述样式应用于 wpf 控件:

Set the ScrollViewer style equal to a style that you build separately. Here are two links where the authors create a style first, and then apply said style to a wpf control after that:

http://www.codeproject.com/Articles/37366/Styling-A-ScrollViewer-Scrollbar-In-WPF.aspx

http://www.eggheadcafe.com/tutorials/aspnet/f51ddf8c-5227-4f1b-a5df-ec3d1b3439ca/styling-the-wpf-scrollviewer.aspx

这篇关于在 ScrollViewer wpf 中更改 ScrollBar 的背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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