代码之家  ›  专栏  ›  技术社区  ›  Pat

如何显示ListViewItem的整行突出显示?

  •  4
  • Pat  · 技术社区  · 16 年前

    我有一个listView,对于view=list,我想让列表项填充控件的整个宽度。也就是说,当您单击一个项目时,整行都将突出显示。

    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.

    有人知道怎么做吗?

    1 回复  |  直到 16 年前
        1
  •  8
  •   Thomas Levesque    16 年前

    您可以绑定 ListViewItem 到…的宽度 ListView :

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


    编辑:您可以设置 ListView.FullRowSelect

    推荐文章