Pat
Pat

Reputation: 16901

How to show full row highlighting for a ListViewItem?

I've got a ListView and, for View = List, would like to have the list items fill up the entire width of the control. That is, when you click an item the whole row is highlighted.

I can't find any setting in the ListView or ListViewItem to control this behavior, and padding with spaces doesn't work very well because I cannot rely on the text being fixed-width.

Anyone know how to do it?

Upvotes: 4

Views: 2677

Answers (1)

Thomas Levesque
Thomas Levesque

Reputation: 292555

You can bind the width of the ListViewItem to the width of the ListView :

...
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="Width" Value="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListView}}}" />
        </Style>
    <ListView.ItemContainerStyle>
...


EDIT: you can set the ListView.FullRowSelect property to true

Upvotes: 8

Related Questions