Wpf如何设置工具提示 [英] Wpf how to set tooltip

查看:96
本文介绍了Wpf如何设置工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在尝试将工具提示设置为文本框,但我一直收到错误:



类型'<的例外情况code> System.NullReferenceException '发生在e-Learning.exe中但未在用户代码中处理

错误:对象引用不是设置为对象的实例



代码:

Hi I am trying to set a tooltip to a textbox progamatically,but i am keep getting the error:

An exception of type 'System.NullReferenceException' occurred in e-Learning.exe but was not handled in user code
The error :Object reference not set to an instance of an object.

the code:

ToolTip tt = new ToolTip();
            tt.Content="Introduceti adresa URL a videocipului";
             loca.ToolTip = tt;





任何想法如何设置工具提示?

如果我不够清楚,我很抱歉。

PSloca是文本框的名称



any ideas how can i set the tooltip ?
I am sorry if i wasn't clearly enough.
P.S "loca" is the name of the textbox

推荐答案

为什么不你在XAML中设置工具提示了吗?

参考这个 http://wpftutorial.net/ToolTip.html [ ^ ]
Why don't you set the tool tip in XAML?
Refer this http://wpftutorial.net/ToolTip.html[^]


好的

if(loca!= null)

{

ToolTip tt = new ToolTip();

tt.Content =Introduceti adresa URL a videocipului;

loca.ToolTip = tt;

}
Okay
if (loca != null)
{
ToolTip tt = new ToolTip();
tt.Content="Introduceti adresa URL a videocipului";
loca.ToolTip = tt;
}


这篇关于Wpf如何设置工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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