How to show full row highlighting for a ListViewItem?
I've开发者_Python百科 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?
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
精彩评论