WPF thumb Dragdelta cross monitor movement

I have a Popup control, I added a thumb, so I can drag it on the screen. The DragDelta event of the thumb is therefore overloaded:

private static void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
{
Thumb thumb = (Thumb)sender;
Popup popup = thumb.Tag as Popup;< br />
if (popup != null)
{
popup.HorizontalOffset += e.HorizontalChange;
popup.VerticalOffset += e.VerticalChange;
}
}

Dragging works perfectly (I used the drag example from here: http://www.codeproject.com/Articles/43636/WPF-A-search), except that the pop-up window arrives The end of the monitor and span to the other (dual monitor setup). For example, if I open a pop-up window on the left monitor and start dragging it to the right, when its right border touches the edge of the monitor, it’s The movement was unstable and started to move around until I moved to the right and showed monitoring on the other one.

I debugged through this scene, and here is a numerical example of what basically happens:< /p>

At edge of screen:
HorizontalOffset = 600
HorizontalChange = 1

Move Right:
HorizontalOffset = 601
HorizontalChange = -800

HorizontalOffset = -199
HorizontalChange = 401

HorizontalOffset = 200
HorizontalChang e = -150

When the pop-up window is moved to another monitor, it will produce a strange stroboscopic effect; what do I need to do to make it transition smoothly between monitors?

I still haven’t figured out how to unbind the pop-up window to the screen, but I was able to use Window control to complete the operation I need. I created WindowStyle.None, so there is no border, and use the delegate of the DragMove() method to override the MouseLeftButtonDown event, so they can be dragged on the screen. This makes my pop-up window have Very similar look and feel, but able to drag it on the screen without flickering.

I have a Popup control and I added a thumb so I can drag it on the screen It. Thumb’s DragDelta event is therefore overloaded:

private static void Thumb_DragDelta(object sender, DragDeltaEventArgs e)
{
Thumb thumb = (Thumb)sender;
Popup popup = thumb.Tag as Popup;

if (popup != null)
{
popup.HorizontalOffset += e.HorizontalChange ;
popup.VerticalOffset += e.VerticalChange;
}
}

Dragging works perfectly (I used the drag example from here: http://www. codeproject.com/Articles/43636/WPF-A-search), except that the pop-up window reaches the end of the monitor and crosses to the other (dual-monitor setup). For example, if I open the pop-up window on the left monitor and start to Drag it to the right, when its right border touches the edge of the monitor, its movement is unstable and starts to move around until I move to the right and display the monitor on the other one.

I Debugging through this scene, here is a numerical example of what basically happens:

At edge of screen:
HorizontalOffset = 600
HorizontalChange = 1

Move Right:
HorizontalOffset = 601
HorizontalChange = -800

HorizontalOffset = -199
HorizontalChange = 401

HorizontalOffset = 200
HorizontalChange = -150

When the pop-up window is moved to another monitor, it produces a strange stroboscopic effect; what do I need to do to make it work? Smooth transition between monitors?

I still haven’t figured out how to unbind the pop-up window to the screen, but I was able to accomplish what I needed by using the Window control. I created WindowStyle.None, so there is no border, and the MouseLeftButtonDown event is overloaded using the delegate of the DragMove() method, so they can be dragged on the screen. This makes my pop-up window have a very similar look and feel, but can be on the screen Drag it without flickering.

Leave a Comment

Your email address will not be published.