I want to display a ToolTip of a Button immediately after clicking on it. The ToolTip should then disappear after a short period of time. This is needed only as a feedback for the user since clicking on the Button causes a string to be copied to the Clipboard.
I used an Button-Behavior to display the Tooltip of the Button via the Click-Event. To display the ToolTip I set its IsOpen property to true.
class ForceToolTipBehavior : Behavior<Button>
{
protected override void OnAttached()
{
base.OnAttached();
this.AssociatedObject.Click += AssociatedObject_Click;
}
private void AssociatedObject_Click(object sender, System.Windows.RoutedEventArgs e)
{
var tooltip = this.AssociatedObject.ToolTip as ToolTip;
tooltip = new ToolTip();
tooltip.Content = "Log was copied to your Clipboard";
tooltip.IsOpen = true;
}
}
This works just fine but the ToolTip stays open. Is there any elegant way make the ToolTip disappear after like a second? Is it possible to use the ToolTipService for that task?
Simple and quick way: