I want to create a little diagraming tool, and i'm stuck on a mouse problem.
I have 2 custom control, one for a node, and one for the edge arrow.
The Node custom control is a border placed onto a grid.
I can drag my node around clicking on the border part and create an arrow with mousedown on the grid part.
What i want is to resize the arrow and make it follow the mouse (drag fake) when i fire mousedown on the grid part.
But for now all the mouse event handlers are in the node custom control, since i'll have another behavior when clicking on the arrow custom control.
I don't need library answers, cause i want to implement it myself.
Any guess ?
Resolved! it wasn't a wpf problem but a coding one, the border and grid MouseEvents were sharing a variable i didn't see, and i had curious behaviors but everything's fine now
Related
I have a problem developing a custom menu item.
The menu item is hosted in a ToolStripControlHost, the rest are just ToolStripMenuItems.
What I want is that when the user hovers the mouse over the custom control, to be selected like an ordinary ToolStripMenuItem, like in the image below. Unfortunately, I did not manage to figure this out. Is this behavior possible?
Edit: 26.10.2015:
I have been playing around with the control and it seems that the ToolStripControlHost, when added to the ContextMenu it is shrinked in the list, like in the image below.
I made the background of the custom control red so it can be seen better. The control only receives MouseHover events only when the mouse is over the control, shown in red. If you point the mouse on the left or the right, the ContextMenu receives the events.
ContextMenu custom menuitem
It is an interesting behaviour, because also the ToolStripTextBox or ToolStripCombobox don't take the whole left to right space and are not highlighted when mouse is over.
Now I hope someone has an idea how to do that.
I am working out of the 3.5 .Net Framework. I have a textbox next to a scroll bar in a stackpanel. I would like it to be that when the user clicks the "up" arrow of the scrollbar, the contents of the textbox are incremented, and decremented when the click the "down" arrow of the scrollbar. The problem is I am not sure which event I need to fire to do this. I've tried MouseDown, MouseUp, PreviewMouseDown (which fires but I don't know how to differentiate whether the up or down arrow was clicked), PreviewMouseUp (same problem), StylusUp, StylusDown, PreviewStylusDown, PreviewStylusUp, StylusButtonDown, StylusButtonUp, and the previews for that also. As I am debugging, I am using messageboxes to let me know I've entered that event, but none have shown (expcept for the PreviewMouseDown). Being fairly new to WPF, I am basically baffled.
Does anyone know which event I should be looking for? Thanks.
You should not abuse the ScrollBar for this but create a new control with two buttons.
I have a WPF ListBox, where the items are styled to be Buttons. I've used gong-wpf-dragdrop to very easily implement drag-and-drop, so I can reorder the listitems. However, I would now like to be able to left-click on one of the buttons to launch an edit action, but the MouseLeftButtonUp event on the ListBox seems to be being swallowed by the drag-and-drop operation. (I'm using EventToCommand from MVVM Light to hook everything up).
Changing the ListBox to respond to MouseRightButtonUp works fine (so I can drag-and-drop with the left mouse button, and launch the edit action with the right mouse button), but I would rather keep the right mouse button for a context menu.
I also tried using MouseDoubleClick, but although that launched the edit action, it always opened the first item in the list for editing, and moved the listitem that was double-clicked to the top of the list - very confusing for everyone concerned!
Any thoughts on how to approach this?
If i understand you correctly, you don't want to drag&drop if you click the button. One way to do that is to hook up with the PreviewMouseLeftButtonDown of the button. Initiate you edit action in the eventhandler and set e.Handled=true. This way the MouseLeftButtonDown will not arrive at the listbox and no drag&drop operation will be initiated. One disadvantage is that the button will react on the mousedown instead of the mouseup (so it's like ClickMode=Press).
Regards,
Rob
I have a silverlight templated control that changes opacity when you hover it . However when user points cursor to its child control the effect wores off. I want to have the control highlighted also when the user hovers any child control. I've did the same thing in WinForms by overriding the WndProc method. Is there something similar in silverlight ?
Thanks
Sounds to me like you have not used the correct events to detect the hover, I suspect you are using MouseMove. Instead Use MouseEnter and MouseLeave events. An MouseEnter event will occur when the mouse moves over the control. You move the mouse over child controls and you will get no further events. Then when the mouse moves completely out of your control you will get MouseLeave.
The UI for my WinForms app is centered around a DevExpress XtraGrid.
Usually, the first thing a user wants to do is scroll the grid, so the normal instinct is to move the mouse wheel.
But currently, you have to click a row in the grid first, which is annoying.
I tried to use BaseView.Focus method, but this did not work - still had to click a row before the wheel would work.
Any suggestions on how to accomplish this?
By default, the Grid is scrolled by mouse wheel only if the mouse pointer is above the grid. So, an attempt to focus it does not help. To change this behavior, you should change the static SmartMouseWheelProcessing property in the form's constructor as shown below:
DevExpress.XtraEditors.Drawing.MouseWheelHelper.SmartMouseWheelProcessing = false;