Reputation: 5236
I have a WPF chart and I'm creating a drag-to-scroll sliding window on the chart. I'm essentially following a MouseDown-MouseMove-MouseUp sequence to track the sliding window movements. I want to manage cases where a MouseMove/MouseUp after a MouseDown occurs outside the chart area. For this, I'm doing a Mouse.Capture(Chart)
on MouseDown and Releasing the capture on MouseUp. But whenever the MouseDown occurs, my window hangs. What am I doing wrong?
Upvotes: 2
Views: 1246
Reputation: 3774
I had the same issue. The problem for me was that the mouse capture for some reason immediately calls the MouseMove event, and I was getting a crash because my mouse move event was expecting a Rectangle to be instantiated in MouseDown. Of course it was still null.
So the stack looks like this:
MouseDown
MouseCapture
MouseMove
then returns to where it left off in MouseDown
Upvotes: 0
Reputation: 188
Maybe you handle mouse events not from Window or UserControl or other UIElement, but on specific element that not inherits from UIElement? You need use
<UserControl x:Class="...
MouseDown="HandleMouseDown"
.../>
Instead of
<ListBox x:Name="...
MouseDown="HandleMouseDown"
.../>
Actually, did the window hangs completely or just does not react to mouse clicks (bot do on keyboard)?
Upvotes: 0