0

I have a ListView wrapped in Grid on top of which I have a panel overlay( How to make overlay control above all other controls?). I would like to highlight a listview item that is under even when the cursor is not directly over it.

enter image description here

I would like to have a highlight like this when the cursor is over the red rectangle.

enter image description here

<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 could I do this?

Similar issue: How to get control with lower zindex when mouse clicked in wpf?

I could set IsHitTestVisible to false but I need panel items to remain clickable so it's not an option.

If only there is some way to set IsMouseOver programmatically...

Konrad
  • 6,385
  • 12
  • 53
  • 96

1 Answers1

0

Set the vertical and horizontal alignment to stretch for the overlay panel

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