开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜