BasedOn property not working with ListView

Posted by bobjink on Stack Overflow See other posts from Stack Overflow or by bobjink
Published on 2010-04-11T18:01:41Z Indexed on 2010/04/11 22:53 UTC
Read the original article Hit count: 270

Filed under:
|

When I use the following code it works because I am using a ListBox

<UserControl.Resources>
    <Style BasedOn="{StaticResource {x:Type ListBox}}" TargetType="{x:Type ListBox}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="Transparent" />
    </Style>
</UserControl.Resources>

But when I use the following code to a ListView I get an warning/exception

<UserControl.Resources>
    <Style BasedOn="{StaticResource {x:Type ListView}}" TargetType="{x:Type ListView}">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Background" Value="Transparent" />
    </Style>
</UserControl.Resources>

"StaticResource reference 'System.Windows.Controls.ListView' was not found."

Why and how to solve it? I want the functionality of a ListView.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf