WinForms Canvas KeyDown event not fired - winforms

Canvas KeyDown Event not working
I have set KeyPreviou on my form to true.
I have set canvas Focusable to true.
I Focus on my canvas control when Mouse is pressed
Any info on this matter did not help me.
Any ideas?

Finally i found what the problem was. I posti it so others will benefit.
Initially i focused on my canvas inside the MouseDown event.
Now i focused on the canvas inside the MouseUp event and all working ok.

Related

How do I capture the mouse when a Silverlight RepeatButton is depressed?

I have a RepeatButton on a UserControl that acts as the up button. The control is a number spinner of sorts. When the number value goes from 9 to 10 the up button is released because it moves out from under the mouse. I know I can capture the mouse, but my RepeatButton is not giving me MouseLeftButtonDown events. So how do I capture the mouse over the RepeatButton when it is depressed and release the capture when it is released? And should the RepeatButton give me MouseLeftButtonDown events?
Edits:
It would seem that the template content is stealing the button's MouseLeftButtonDown events. Is there anyway I can circumvent the button's content. If I set HitTestVisible to false, the button itself becomes untouchable. I wish silverlight had OnPreview overrides.
Have you tried utilising MouseLeftButtonUp instead to check if it can occur when the mouse button is released?
I just had a similar problem with Windows 8/WinRT and found a workaround - you can bind something to the button's IsPressed property and when it gets set to false - it means the button/touch is up.

Highlighting control when mouse is over child control

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.

Mouse events between two ItemsContorl elements

Take a look at below code. BoxControl has MouseLeftButtonDown/MouseLeftButtonUp events and those work fine when the mouse is clicked on
the box control other than when the mouse is clicked on below text block. I want MouseLeftButtonDown/MouseLeftButtonUp events of BoxControl
to work when the mouse is clicked on below textblock. Appreciate your help!
It works as expected. Your BoxControl is the one which has the click events so that is the only control which is listening for these events, and TextBlock isn't.
There are two things you can do:
1) Add the TextBlock in your BoxControl
OR
2) Add the MouseLeftButtonDown and MouseLeftButtonUp events on your current TextBlock and get these textblock_MouseClickHandlers to delegate to the event handlers for the BoxControl
You should hook into the PreviewMouseLeftButtonDown and PreviewMouseLeftButtonUp events instead. Make sure to mark them as handled if you don't want them to bubble up any further.

How to detect MouseLeave on a UIElement that is a Drag source in Silverlight when Dragging?

I have a StackPanel with MouseLeave events. I have run into an issue where MouseLeave events are not occurring for this StackPanel when elements are being dragged from this stack panel to other outside elements.
How can I have the MouseLeave event detected when Dragging?
Thank you.
See if the DragLeave event accomplishes what you want:
http://msdn.microsoft.com/en-us/library/system.windows.uielement.dragleave(VS.95).aspx

Any way to make WPF Adorner ignore mouse?

Is there any way to make WPF adorner ignore mouse entirely so that the UIElement behind the adorner still gets mouse events as if the adorner does not exist?
Set the IsHitTestVisible property of the Adorner to false
If you use the tunneling version of the mouse events rather than the bubbling events (i.e., PreviewMouseDown instead of MouseDown), you will receive the mouse events from the UIElement first, and be able to stop them from reaching the adorner by setting e.Handled to true.

Resources