This is a migrated thread and some comments may be shown as answers.

Handle the ToolTip logic globally

1 Answer 115 Views
ToolTip
This is a migrated thread and some comments may be shown as answers.
Janko
Top achievements
Rank 1
Janko asked on 06 Jun 2019, 11:12 AM
I want to handle the tooltip logic globally for all UIElements of my RadWindow.
More precisely, the UIElement under the mouse pointer should be used to decide what ToolTip content is shown and whether the Tooltip is shown.

Is that possible by using e.g. RadToolTip/ RadToolTipService/ ToolTip or do I need something else?

----


If it is unclear what I mean, here is a similar behaviour I've already implemented. However it is used for the RadContextMenu instead of a tool tips.
 (i.e. the clicked UIElement is used to decide what Context Menu is shown and whether the context Menu is shown.)


        // this xaml is somewhere very high in the visual tree and therefore handles all children of that node
        <telerik:RadContextMenu.ContextMenu>
            <telerik:RadContextMenu x:Name="MyContextMenu" Opening="RadContextMenu_Opening">
                <telerik:RadMenuItem x:Name="Item1" Header="Item1"/>
                <telerik:RadMenuItem x:Name="Item2" Header="Item2"/>
                <telerik:RadMenuItem x:Name="Item3" Header="Item3"/>
            </telerik:RadContextMenu>
        </telerik:RadContextMenu.ContextMenu>



        private void RadContextMenu_Opening(object sender, Telerik.Windows.RadRoutedEventArgs e)
        {
            e.Handled = true; // do not show context menu except if I say otherwise further below

            var source = MyContextMenu.GetClickedElement<FrameworkElement>();
            if (source == null)
                return;
            var itemToShowContextMenuFor = GetViewModelFromBestParentInVisualTreeOrNull(source)
            if (itemToShowContextMenuFor == null)
                return;

            // e.g. set visibility for each RadMenuItem
            SetContextMenuItems(itemToShowContextMenuFor, out var showContextMenu)

            if (showContextMenu)
                e.Handled = false; // show context menu
        }

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 07 Jun 2019, 10:08 AM
Hello Janko,

The tooltips in the WPF framework appear when you mouse enter the corresponding element. This means that there is no convenient approach (like with the context menu) to define a global tooltip on the root UI element because you are always in mouse over state of the element. 

The most convenient approach would be to manually set the RadToolTipService.ToolTipContent or the native ToolTip property of the elements that should display a tooltip. 

Regards,
Martin Ivanov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
ToolTip
Asked by
Janko
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or