How to apply WPF ScrollBar style to a particular listview?

一笑奈何 提交于 2020-01-03 16:50:54

问题


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:


Add the style as a resource to the ListView itself.

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


来源:https://stackoverflow.com/questions/5163259/how-to-apply-wpf-scrollbar-style-to-a-particular-listview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!