From 847dd47f01bc50b63da2540fc95d8f55e709e832 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 6 Oct 2019 10:46:55 -0700 Subject: [PATCH] Fix ListView click locator The code that figures out which row and column you clicked in wasn't taking horizontal scrolling into account. Issue #49. --- CommonWPF/WPFExtensions.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CommonWPF/WPFExtensions.cs b/CommonWPF/WPFExtensions.cs index 4d33c9f..890b4b9 100644 --- a/CommonWPF/WPFExtensions.cs +++ b/CommonWPF/WPFExtensions.cs @@ -147,9 +147,13 @@ namespace CommonWPF { // for it, so for now just fudge it. const int FUDGE = 4; + // Need to take horizontal scrolling into account. + ScrollViewer sv = lv.GetVisualChild(); + double scrollPos = sv.HorizontalOffset; + Point p = e.GetPosition(lv); GridView gv = (GridView)lv.View; - double startPos = FUDGE; + double startPos = FUDGE - scrollPos; for (int index = 0; index < gv.Columns.Count; index++) { GridViewColumn col = gv.Columns[index];