我有一个 ListView,对于 View = List,我想让列表项填满控件的整个宽度。也就是说,当您单击一个项目时,整行都会突出显示。
我在 ListView 或 ListViewItem 中找不到任何设置来控制这种行为,并且用空格填充效果不太好,因为我不能依赖固定宽度的文本。
有人知道该怎么做吗?
最佳答案
您可以绑定(bind)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
属性为真
关于.net - 如何显示 ListViewItem 的整行突出显示?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3136378/