I've got a WPF application with a ListBox
in it. For this list box, I'd like to mimic the behaviour of the users control panel (since Windows Vista) -- that is: you single-click on a list item, and it's the same as double-clicking.
In Win32, I'd do this by turning on the LVS_EX_ONECLICKACTIVATE style.
In WPF, I've attempted to do this by handling the MouseLeftButtonUp
event. Unfortunately, and this is odd, it sometimes picks up the wrong item.
For example, if you double-click the title bar (caption) to maximise the window, the second mouse-up occurs over the list box, and the event is raised. Similarly, if an item is partially in view, clicking on it scrolls it into view, but the mouse-up is raised against the item that's now in view, not the one clicked.
Now, again, if this was Win32 (before LVS_EX_ONECLICKACTIVATE), I'd get mouse capture on the mouse down, remember the item, and check that I had capture on mouse up.
But it's not Win32, it's WPF. How do I do single-click activation in a WPF list box?