如何将 WPF ScrollBar 样式应用于特定列表视图?

发布于 10-20 00:25 字数 333 浏览 6 评论 0原文

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

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

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

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

这让我发疯。

谢谢。

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.

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?

This is driving me crazy.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

星星的軌跡2024-10-27 00:25:04

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

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

Add the style as a resource to the ListView itself.

<ListView>
    <ListView.Resources>
        <Style TargetType="ScrollBar">
            ...
        </Style>
    </ListView.Resources>
</ListView>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文