c# - 列表视图覆盖和突出显示列表视图项目
问题描述
我有一个包裹在 Grid 中的 ListView,在它上面有一个面板覆盖(如何在所有其他控件之上制作覆盖控件?)。我想突出显示即使光标不在其上方的列表视图项。
当光标位于红色矩形上方时,我希望有这样的高光。
<Grid Name="grid">
<ListView Name="timeSpansListBox" SelectionMode="Extended" HorizontalAlignment="Left" Width="{Binding ElementName=timePanel, Path=ActualWidth}">
...
</ListView>
<!-- our overlay -->
<MyPanel Name="timePanel" Panel.ZIndex="999">
... items (rectangles you can see on the image)
</MyPanel>
</Grid>
我怎么能这样做?
类似问题:如何在 wpf 中单击鼠标时以较低的 zindex 获得控制?
我可以设置IsHitTestVisible
为,false
但我需要面板项目保持可点击状态,所以它不是一个选项。
如果只有某种方式可以以IsMouseOver
编程方式设置...
解决方案
设置垂直和水平对齐以拉伸覆盖面板
<MyPanel Name="timePanel" Panel.ZIndex="999"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch">
... items (rectangles you can see on the image)
</MyPanel>
推荐阅读
- r - R:在分组列中变异非零最小值
- python-3.x - 使用 .fit() 方法时,解码器的某些变量不存在梯度。帮助需要
- ios - 为什么 UIView.animate 在 view.layer 和 sublayer 上执行不同的结果
- html - 如何强制溢出元素从顶部开始
- vba - 访问 VBA,无法关闭当前窗体。错误 2585 处理表单或报表事件时无法执行此操作
- android - 具有自定义权限的 Android 广播
- jdbc - 使用 Denodo 驱动程序更改超时 jaydebeapi
- java - 如何进行测试,测试字符串是否有大写、小写、特殊字符?
- java - 在 Spring 应用程序中添加 Apache Camel 自定义组件/端点
- android-studio - java.lang.NullPointerException:null 不能转换为非 null 类型 com.google.android.gms.maps.SupportMapFragment