Issue with dependency properties

Topics: fixed
Apr 21, 2009 at 7:53 AM
hi,when I write the code as follows:

            GreenButton.SetValue(ToolTipService.ToolTipProperty, "1111");
            GreenButton.SetValue(ToolTip.ShowDurationProperty, 30);
            GreenButton.SetValue(ToolTip.InitialDelayProperty, 1);
            //GreenButton.SetValue(ToolTip.ContentProperty, "1111");

it doesn't work.only xaml is supported or something I wrote wrong.
Apr 21, 2009 at 9:34 AM
Hi, thx for the very useful reply!

To point you in a good direction, below you can find 2 examples of code that should do the trick:


redToolTip =

new ToolTip {Content = "1111"};



ToolTip.ShowDurationProperty, 30);



ToolTip.InitialDelayProperty, 1);



ToolTipService.ToolTipProperty, redToolTip);



redToolTip =
new ToolTip{ InitialDelay = 0, ShowDuration = int.MaxValue, Content = "This is a persistent ToolTip."};



ToolTipService.SetToolTip(RedButton, redToolTip);



What went wrong in your code, is the fact that you are trying to change the ToolTip's properties by setting the value of it's dependency properties onto a button.
In a new release (very soon), I'll catch this with a proper error stating that you should only set the value of the ToolTip dependency properties on a ToolTip object.

Personally, I prefer example 2 as it is easier to understand what you are doing.
Example 1 will be supported in the next release (I'll reply here when I released the fix for this).

Did this solve your question in a sufficient way?
Again thx for the remark, and feel free to ask any further questions or post any new remarks.

Xavier Decoster

Apr 21, 2009 at 9:35 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Apr 21, 2009 at 9:51 AM
fixed in release v1.2
Apr 27, 2009 at 6:03 AM
thanks for your great job,I will try this.
hope this can be solved in silverlight 3.
what's more,where are you from?you work in Microsoft?