【问题标题】:Listview overlay and highlighting listview items列表视图覆盖和突出显示列表视图项目
【发布时间】:2019-09-03 00:00:00
【问题描述】:

我有一个包裹在 Grid 中的 ListView,在它上面有一个面板覆盖 (How to make overlay control above all other controls?)。我想突出显示即使光标不在其上方的列表视图项。

当光标在红色矩形上时,我希望有这样的高亮显示。

<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>

我该怎么做?

类似问题:How to get control with lower zindex when mouse clicked in wpf?

我可以将IsHitTestVisible 设置为false,但我需要面板项目保持可点击状态,所以这不是一个选项。

如果只有某种方法可以以编程方式设置IsMouseOver...

【问题讨论】:

    标签: c# wpf xaml


    【解决方案1】:

    设置垂直和水平对齐以拉伸覆盖面板

    <MyPanel Name="timePanel" Panel.ZIndex="999"
             HorizontalAlignment="Stretch" 
             VerticalAlignment="Stretch">
        ... items (rectangles you can see on the image)
    </MyPanel>
    

    【讨论】:

      猜你喜欢
      • 2012-11-21
      • 1970-01-01
      • 2014-01-14
      • 1970-01-01
      • 2012-05-09
      • 2013-10-26
      • 1970-01-01
      • 2012-04-19
      • 1970-01-01
      相关资源
      最近更新 更多