I'm trying to determine if a user has right clicked on an existing listbox entry or the empty portion, to enable or disable context menuitems.
In WinForms (for a datagridview) i was able to do
var result = DGVTasks.HitTest(e.X, e.Y);
bool existingRowSelected = result .Type == DataGridViewHitTestType.Cell;
in a datagridview. Now in WPF i've tried
Point pt = e.GetPosition((UIElement)LBXWorkflow);
HitTestResult result = VisualTreeHelper.HitTest(LBXWorkflow, pt);
Result.VisualHit shows textbox if i click on existing text, but border if i click on blank space before or after the text on an existing line (which would return a false negative if i use it to determine if an entry was right clicked).
Any ideas, for both Listbox and DataGrid?