强制 WPF 工具提示留在屏幕上 [英] Forcing a WPF tooltip to stay on the screen

查看:24
本文介绍了强制 WPF 工具提示留在屏幕上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个标签的工具提示,我希望它保持打开状态,直到用户将鼠标移动到不同的控件.

I have a tooltip for a Label and I want it to stay open until the user moves the mouse to a different control.

我在工具提示上尝试了以下属性:

I have tried the following properties on the tooltip:

StaysOpen="True"

ToolTipService.ShowDuration = "60000"

但在这两种情况下,工具提示仅显示 5 秒.

But in both cases the tooltip is only displayed for exactly 5 seconds.

为什么这些值会被忽略?

Why are these values being ignored?

推荐答案

只需将这段代码放在初始化部分即可.

Just put this code in initialization section.

ToolTipService.ShowDurationProperty.OverrideMetadata(
    typeof(DependencyObject), new FrameworkPropertyMetadata(Int32.MaxValue));

这篇关于强制 WPF 工具提示留在屏幕上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆