Programs that do support drag-and-drop often use it as a shortcut for advanced users, rather
than a standard way of working.
WPF changes very little about drag-and-drop operations. If you??™ve used them in Windows
Forms applications, you??™ll find the programming interface is virtually unchanged in WPF. The
key difference is that the methods and events that are used for drag-and-drop operations are
centralized in the System.Windows.DragDrop class and then used by other classes (such as
UIElement).
Essentially, a drag-and-drop operation unfolds in three steps:
1. The user clicks an element (or selects a specific region inside it) and holds the mouse
button down. At this point, some information is set aside and a drag-and-drop operation
begins.
2. The user moves the mouse over another element. If this element can accept the type
of content that??™s being dragged (for example, a bitmap or a piece of text), the mouse
cursor changes to a drag-and-drop icon. Otherwise, the mouse cursor becomes a circle
with a line drawn through it.
3. When the user releases the mouse button, the element receives the information and
decides what to do with it. The operation can be canceled by pressing the Esc key
(without releasing the mouse button).
You can try out the way drag-and-drop is supposed to work by adding two TextBox objects
to a window that have the built-in logic to support drag-and-drop.
Pages:
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353