How to apply WPF ScrollBar style to a particular l

2019-07-04 06:00发布

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.

1条回答
祖国的老花朵
2楼-- · 2019-07-04 06:08

Add the style as a resource to the ListView itself.

<ListView>
    <ListView.Resources>
        <Style TargetType="ScrollBar">
            ...
        </Style>
    </ListView.Resources>
</ListView>
查看更多
登录 后发表回答