Questions regarding the Noesis Inventory (Drag'n'Drop) Example
Posted: 28 Oct 2022, 08:46
Hello,
Being a WPF/xaml rookie, I've got numerous questions and areas of confusion, so bear with me while I ask a few of the most pertinent here pertaining to the Inventory sample:
1. It is my understanding that the DragAdornerBehavior, being applied fairly high in the element hierarchy in the xaml, actually applies to all UiElements. E.g. even the slots (head, ring, chest, etc.) where the inventory items can be dragged to, will have the DragAdornerBehavior applied to them. I'm assuming this is intentional, but I would have thought this behavior is only relevant to apply to the inventory elements themselves (sword, shield, ring), no?
2. The complete drag and drop behavior is spread over multiple objects/elements including DragAdornerBehavior, DropItemBehavior, DragItemBehavior. Assuming I want the ability to reposition lots of widgets arbitrarily within a single canvas, i.e. not into explicit slots, is it possible/reasonable to combine all of this code into a single Behavior?
One problem that comes to mind for me, is that the position of UiElements' is sometimes determined by the parent element, but looking into DragAdornerBehavior - which simply references its current position with an offset - this doesn't seem to be an issue?
3. The item being dragged is rendered under the mouse cursor by applying TranslateTransform and assigning DraggedItemX, DraggedItemY to the x,y position of the object, respectively. As an extension to the previous question, is this 'best practice'? Would it be feasible to instead have the rendering x/y offset set by the backend code?
4. Why do some callbacks have 'Preview' prefixed to them? E.g. PreviewMouseMove, compared to DragOver, or Drop?
I hope these questions aren't too silly.
Thanks in advance,
Gazoo
Being a WPF/xaml rookie, I've got numerous questions and areas of confusion, so bear with me while I ask a few of the most pertinent here pertaining to the Inventory sample:
1. It is my understanding that the DragAdornerBehavior, being applied fairly high in the element hierarchy in the xaml, actually applies to all UiElements. E.g. even the slots (head, ring, chest, etc.) where the inventory items can be dragged to, will have the DragAdornerBehavior applied to them. I'm assuming this is intentional, but I would have thought this behavior is only relevant to apply to the inventory elements themselves (sword, shield, ring), no?
2. The complete drag and drop behavior is spread over multiple objects/elements including DragAdornerBehavior, DropItemBehavior, DragItemBehavior. Assuming I want the ability to reposition lots of widgets arbitrarily within a single canvas, i.e. not into explicit slots, is it possible/reasonable to combine all of this code into a single Behavior?
One problem that comes to mind for me, is that the position of UiElements' is sometimes determined by the parent element, but looking into DragAdornerBehavior - which simply references its current position with an offset - this doesn't seem to be an issue?
3. The item being dragged is rendered under the mouse cursor by applying TranslateTransform and assigning DraggedItemX, DraggedItemY to the x,y position of the object, respectively. As an extension to the previous question, is this 'best practice'? Would it be feasible to instead have the rendering x/y offset set by the backend code?
4. Why do some callbacks have 'Preview' prefixed to them? E.g. PreviewMouseMove, compared to DragOver, or Drop?
I hope these questions aren't too silly.
Thanks in advance,
Gazoo