XAML ToolTip + IsHitTestVisible = "False"

We need to have mouse clicks and drag “ignored” by our view1, but the tooltip should still function in that view. The reason is that View1 is above View2 in Z-Order, so View1 can tint View2 in red and display a warning using ToolTip; however, the tooltip accompanying View1 will not work if IsHitTestVisible = "False".

Does anyone know the work, so the tooltip will be displayed when moving / moving the mouse, and other mouse events are ignored by View1 and go to View2?

Thank,

Sean

+5
source share
3 answers

What I did, which is not very good:

    private void UserControl_Loaded(object sender, RoutedEventArgs e)
    {
        var parentWindow = Window.GetWindow(this);
        var source = PresentationSource.FromVisual(parentWindow) as HwndSource;

        source.AddHook(WndProc);
    }

    private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
    {
        // Handle messages... 
        if (msg == WM_MOUSEMOVE)
        {
        ...show tool tip if mouse is over it
        }
        return IntPtr.Zero;
    }
+2
source

If someone is faced with the same problem, they may be helpful. We had a requirement to disable several rows in the datagrid, but at the same time allow navigation on them on the ARROW. That's why we had to switch to IsHitTestVisibleinstead of managing the property IsEnabled. Therefore, we could not make the decision above about switching to a property IsEnabled.

. RowEnable DataGridRow. viewmodel virtual. DataGridCell, IsHitTestVisible false viewmodel. , , /, /. , RowEnabled, /. , .

, !

+2

IsHitTestVisible="False"!

IsEnable = false
ToolTipService.ShowOnDisabled="True"
0

All Articles