To get out of control

I am improving the standard WPF TabControl. I want to add undocking functions to it: the user drags the page outside the TabControl, and this page undocks in the window. I want two events in this control - PageDragStart (goes up when the page is dragged out) and PageDragEnd (goes up when the page goes out of bounds)

I have no problem with the first event.

But the second ... OnDrop does not call, because the element is discarded outside the tabcontol container. How can I find out that it has been reset?

PS I want a universal control (therefore, the unlock functionality should not be connected and hard-coded using the tabcontrol window or something like that)

+3
source share
2 answers

Why use DoDragDropat all? As I read your description, using Mouse.Captureit alone seemed like an obvious solution:

  • Process OnMouseLeftButtonNext on the tab and start recording
  • Handle OnMouseMove on the tab and refresh the cursor based on impact testing.
  • OnMouseLeftButtonUp handle on tab and stop capture and make appropriate changes

Reasons why you might think of DoDragDrop over a simple mouse capture:

  • Integration with Windows OLE drag and drop so you can drag and drop between applications and technologies.
  • The modal nature of the DoDragDrop call (which actually seems more disadvantageous to me)
  • Automated target testing.
  • API- "drop operation", ..

, -, OLE , , , DoDragDrop .

+1

- . .

, PageDragStart, Mouse.Capture(, CaptureMode.SubTree); - - DoDragDrop (COMException, NullReference ( , null) , ). PageDragEnd ( IsPageDraggingOut true).

, . .

, ( , Mouse.Capture)?

0

Source: https://habr.com/ru/post/1727301/


All Articles