I want that when hovering over an app element, the tooltips are not displayed in a popup, but displayed in the app's TextBlock. My knowledge allowed me to achieve it this way. First, I make the resource hint invisible:
<Style x:Key="{x:Type ToolTip}" TargetType="ToolTip">
<Setter Property="OverridesDefaultStyle" Value="true" />
<Setter Property="HasDropShadow" Value="True" />
</Style>
Next, I write the hint text and events in each element where I want a hint:
WPF:
<Button Content="Button"
ToolTip="Tooltip text 1"
ToolTipOpening="ToolTip"
ToolTipClosing="ToolTip" />
<CheckBox Content="CheckBox"
ToolTip="Tooltip text 2"
ToolTipOpening="ToolTip"
ToolTipClosing="ToolTip" />
(Similarly, other items)
C#:
public void ToolTip(object s, ToolTipEventArgs e)
{
TextBlock.Text =
e.RoutedEvent == ToolTipService.ToolTipOpeningEvent
? (s as FrameworkElement).ToolTip : string.Empty;
}
It works. But is it possible not to indicate events in the element (ToolTipOpening="ToolTip"
and ToolTipClosing="ToolTip"
), but to achieve the desired effect by simply specifying a hint in the element (ToolTip="Tooltip text"
)? Thank you.