Silverlight - how to make "up" Event - silverlight

I have an user control with elements inside. And this User control displays in popup window. I should hide popup window when user mouse leave from popup, so I should catch mouse leave from elements on user control. How to do it?

Related

Scrollviewer messing with focus

I have a window (with on-screen keyboard) on top of a user control of another window.
I want when the user clicks outside of the keyboard window, the keyboard window to be closed. For this I'm using the onlostFocus and Deactivated events, in which i call the method HideKeyboardWindow().
In the user-control I have a grid with 1 row. When the keyboard is open and I click on the row of the grid, HideKeyboardWindow() isn't called. However, when I wrap the row with a ScrollViewer, then HideKeyboardWindow() is called.
Why is the scrollviewer messing with the focus?
The GotFocus event is not a good event to use for your purpose because it can be raised at inappropriate times, such as when the user mouses over the inner controls of your keyboard for example. A better solution would be to simply attach an additional MouseDown handler to the parent control. When the parent handler receives the event, the user has clicked outside the keyboard control.

Silverlight: How to route mouse events from one control to another?

If I catch mouse move/mouse button down events in one control, how do I route the caught event to another control?
In MSDIN documentation I found WPF UIElement.RaiseEvent but it seems it doesn't exist in Silverlight.
The reason for this question is the following issue.
I have an application where user is able to pick a control on the screen to retrieve control's ID (a custom property). While user picks a control, I don't want default actions of the control to be triggered - no button clicks, no text highlighting, no link navigation etc. That's why when entering the "picking mode", I put a transparent overlay over my application and after user clicks on it I find the element behind the overlay, get its ID and remove the overlay.
This approach is working fine except one scenario when there is a scroll viewer on the screen and user might want to pick an element which is scrolled out of view. Thus when picking elements, user at first clicks on a scrollbar to scroll the required element into view, but the scrollbar doesn't work because its behind the overlay.
Currently I have working code which detects if the element under mouse cursor (and behind the overlay) is a scrollbar instance, and thus I ignore it for my picking process - my application doesn't require picking scrollbars. But how do I pass the mouse event from the overlay to the scrollbar behind?
The short answer is, you can't route the mouse events.
But what you can do is: as long as the mouse is hovered over a Scrollbar you can set the IsHitTestVisible property of your mouseClick catcher overlay to false. The click will just go through it. Or can you only detect the Scrollbar the moment the user clicks?

Making UserControl transparent to mouse clicks

Is it possible for a UserControl to be transparent to mouse clicks/drags etc. and pass them to the control underneath it?

notification code for mouse over a tab item

I have a tab control created by CreateWindowEx(NULL, WC_TABCONTROL,...). I would like to have a notification when a mouse is over a tab item. The tab control has the style TCS_TOOLTIPS and when the mouse is over a tab item for an amount TTDT_INITIAL ms (whose default value is double click time), it will display a tooltip.
But I also need a notification immediately when a mouse is over a tab item. But I don't want to modify the TTDT_INITIAL value. In fact, when a mouse is over a non-selected tab item, it will change the color to blue by default. But I can not find the notification (and its receiver) for this thing.
So I would like to know if there is a way to be notified immediately when a mouse is over a tab item (winapi only).
There is no notification for that particular purpose. The tabs are not their own controls, the entire TabControl as a whole is one control. What you can do is have your window procedure for the TabControl catch WM_MOUSEMOVE messages, and then call TabCtrl_HitTest() to determine which tab is currently underneath the mouse. Keep track of the current tab so you can detect when the mouse moves across a tab boundary onto a new tab.

Window GotFocus event not firing

I couldnt get the GotFocus() event fired in the WPF window by clicking. But if I click any controls, it will be fired.
My requirement is as follows: I have a hostwindow which has a viewport with two datagrids which can host user controls. I do animations like flip and fade on this user controls. I am using a transparent background(glass effect) for the controls. But when one user control get on top of the other, both of them overlap. So I want to make the top one opaque when the user click on one user control.
Try using the Activated event, as GotFocus is intended to be used only with controls.

Resources