I have a WPF ListView. This ListView will contain n-items.
As a user drags something into the listview, I am displaying a horizontal bar on the AdornerLayer of the ListView to show the index where the item will be inserted.
I also am auto-scrolling the listView. Because ScrollViewer.CanContentScroll=”False” ListViewItems are partially visible.
The problem I am having is that the indicator bar that I am drawing is appearing outside of the bounds of the ListView (in my case above) when the ListViewItem I am over is at the top and only partially visible.
The trigger to draw the bar is to take whatever ListViewItem I am currently hovering over, grab it’s top bounds value and draw the line. When the ListViewItem is not fully visible yet, the bar is draw above the ListView itself and obviously looks weird.
Summary: Trying to determine if a given ListViewItem is only Partially visible in a ListView.
In this case, code is not really all that relevant but I can post some if you like.
Thanks
You can probably use a combination of
ScrollViewer.VerticalOffsetorScrollViewer.ViewPortHeightand the listviewitem’s location with respect to the listview itselfTo tell if it is fully visible you should just need to do the following
Then if that value is between the
itemHeightor-viewPortHeight, then it is visibleOR, what is probably a little cleaner: