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
}
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
}