ScatterViewItem Drag and Drop into RichTextBox - c#

I have a ScatterView which consist of 2 items: an Image and a RichTextBox. RichTextBox has AllowDrop set to true.
When I drag the Image to the RichTextBox, the image disappears completely but RichTextBox's DragEnter and Drop event did not fire at all. Neither did PreviewDragEnter nor PreviewDrop.
I tried setting RichTextBox's AllowDrop to false, and the Image landed on top of the RichTextBox as expected.
How do I get the DragEnter and Drop event of RichTextBox to fire? The only thing that fires is the ScatterView's Drop event.

Drag & drop with Surface controls (like ScatterView) is different from normal Windows drag & drop. The thing being dragged is a 2d shape (not a single point) which could have multiple inputs dragging it around. Because of this, we couldn't shim the Surface drag drop functionality into the existing WPF drag drop APIs. Instead, you'll need to use attached events from the SurfaceDragDrop object like http://msdn.microsoft.com/en-us/library/microsoft.surface.presentation.surfacedragdrop.dragenter.aspx which are very similar to the WPF equivalents but enable Surface-friendly user experiences.

Related

Seamlessly passing drag&drop actions from children controls to parent ScatterViewItem

I am using Surface 2.0 SDK and my application uses dynamically created custom controls which consist of a ScatterViewItem which holds a Grid with a Menu inside each column.
When initiating a drag&drop motion on any area inside the ScatterViewItem including the Grid, or the margins around the Menu, the ScatterViewItem is being dragged along nicely together with its contents.
However, when trying to initiate such a motion anywhere inside the Menu control, nothing happens. It seems like the necessary events are being swallowed by it.
I have tried extending the Menu class to create a custom control and use a RoutedEvent to handle captured mouse clicks within the ScatterViewItem, but can't quite find a way to seamlessly handle drag events and pass them on to the parent ScatterViewItem
Can anyone share some knowledge on how to implement this?

How can I disable the drag event in LibraryBar control

There are some LibraryBarItems in a LibraryBar control, when I drag horizontally, all the LibraryBarItems move.
But I need to disable this drag event, this means that when I drag the LibraryBar horizontally, nothing happens.
p.s. Actually I want to implement the drop event in horizontal direction rather than in Vertical direction.
I'd suggest adding a transparent visual item over the top of the control to capture input and only allow it through if want it to get through.

Drag-Drop a Control between multiple canvas

Greetings,
I need to be able to drag and drop items that's contained in a Border.
So far I managed to find the border on the MouseLeftButtonDown event.
Now I wish for the item to move with the mouse when I have my mousebutton down.
I assume this can be done by simple settinga bool "dragging" to true when the item is clicked and then handle the moving in the MouseMove event.
But I can't seem to figure out how to move the item. Border doesn't have a property as Position or Location. Is there any way I can achieve what I want?
Perhaps there are controls for it that I dont know of?
Bit more background information:
I'm showing multiple columns (each column is a new canvas) with rows in it. Each row and canvas represent a cell. In a some cells I have a border containing a textblock with information. Upon clicking this border I wish for it to be bound to my mouse and move where I move my mouse.
I would recommend you use the Silverlight Toolkit which contains a framework for doing this sort of drag and drop work. Once installed open the documentation and lookup the PanelDragDropTarget control.

In WPF, how can I capture mouse on a Canvas and still find what controls the cursor is hovering over?

I have a custom Canvas control (inherited from Canvas) overlaid over a large area of User Controls. The idea is to draw paths between user controls (i.e. connector lines).
To capture mouse movement, I call Mouse.Capture(theCanvas) on MouseDown. This works beautifully, but the user controls under the canvas obviously no longer receive mouse events. Mouse.DirectlyOver always shows the canvas, so I can't really fake it by peeking at the current position and seeing which user control it's over.
So, I still need the Canvas for drawing paths, but how can I solve this one of the following ways:
Peek under the Canvas and see what the topmost control is right under it?
Get this MouseDown -> Track MouseMoves -> MouseUp workflow to work on the canvas without mouse captures?
Any other ideas welcome...
I'd agree that those are your two options. If you want to only forward some clicks to your usercontrols, then go with option 1, and hit test the controls under the canvas.
If you need your usercontrols to behave as though there is nothing covering them (textboxes, buttons etc), then i'd recommend using the PreviewMouseMove event on the user control's parent, as this can pick up and optionally "handle" events before the controls get at the event, but it won't block the event if you don't set handled to true

ToolStrip control never fire Enter/Leave event?

I created a movable panel in WinForms. I use a ToolStrip as a titlebar in the panel. I'll use the ToolStrip to move the panel as well as indicating the panel is "active" or not. So when the panel is active, I want to change the ToolStrip's BackColor to Red.
UPDATE: The panel will host other controls, such as a listview. I want the panel being shown as "active" when the hosted control get focus, kind like the behavior of a normal window, whereas the window becomes the panel, and the titlebar becomes the ToolStrip.
When the panel is considered as "active"
hosted control get focus
ToolStrip being MouseDown/MouseClick
ToolStrip being dragged by mouse
The idea is capturing ToolStrip's Enter/Leave event to change the color, but it seems those events are never fired.
Are those events truly never fired? Should I capture other events?
mmmm there are a few ways to do this I guess.
You could use hook into the IMessageFilter message and see if its over your toolstrip/panel and then act accordingly (WM_LBUTTONDOWN, WM_MOUSEMOVE, WM_LBUTTONUP etc - see windows documentation on WIndows Messages for hex message codes for all windows messages). There are many examples about - for example: How to detect if the mouse is inside the whole form and child controls?
Setting a boolen based on whether active or not, an override in the paint can allow the colour settings - or simply flip them along with/instead of the boolean. Same for moving, set a boolean for move active/or not - and then allow WM_MOUSEMOVE to move the form/panel (or not) as needed.

Categories

Resources