如何将 WPF 滚动条样式应用于特定的列表视图? [英] How to apply WPF ScrollBar style to a particular listview?

查看:36
本文介绍了如何将 WPF 滚动条样式应用于特定的列表视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是我的滚动条样式.

Ok, here is my scrollbar style.

<Style x:Key="{x:Type ScrollBar}" TargetType="{x:Type ScrollBar}">       
    <Setter Property="Background" Value="#D5E0FF" />
</Style>

如果我应用这个,毫无疑问,我的应用程序中的所有滚动条都会受到影响.

If I apply this, all scrollbars in my application will get affected, undoubtedly.

现在我的应用程序中有 2 个列表视图,我只需要将此样式应用于特定的列表视图,而另一个保持默认滚动条,知道吗?

Now I have 2 listview(s) in my application, I need to apply this style to only a particular listview, while another one remain default scrollbar, any idea?

这让我发疯.

谢谢.

推荐答案

将样式作为资源添加到 ListView 本身.

Add the style as a resource to the ListView itself.

<ListView>
    <ListView.Resources>
        <Style TargetType="ScrollBar">
            ...
        </Style>
    </ListView.Resources>
</ListView>

这篇关于如何将 WPF 滚动条样式应用于特定的列表视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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