0

I am trying to set a tooltip to a textbox progamatically,but i 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;

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

Soner Gönül
  • 97,193
  • 102
  • 206
  • 364
SGS
  • 11
  • 2
  • Related: [What is a `NullReferenceException` and how do I fix it?](http://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Soner Gönül May 15 '15 at 11:42
  • yes loca is null how can i change it ? – SGS May 15 '15 at 11:44
  • loca is a textbox.i am reading it right now – SGS May 15 '15 at 11:47
  • Can you post some more code? Like your `xaml` where you have added that `TextBox` "loca" and `ViewModel`/Code behind where you are instantiating or accessing that `TextBox`. – Nitin Joshi May 15 '15 at 12:38
  • here is the xaml of the textbox and that is the code i wrote in the .cs file,it is triggered by chosing a radio button. As grant winney said, loca is null,but i dont know how i can istantiate it, and i am new to wpf(&still learning c#) – SGS May 15 '15 at 12:52

0 Answers0