Lohit
Lohit

Reputation: 137

Overriding ToolTip in WPF

I have a custom control in WPF where I want to define a dependency property called ToolTip (of type string). There is already one ToolTip property present in FrameworkElement (of type Object), which I don't want to use. I have defined my own ToolTip property which is of type String.

Example:

public new String ToolTip
        {
            get
            {
                return (String)GetValue(ToolTipProperty);
            }
            set
            {
                SetValue(ToolTipProperty, value);
            }
        }

Now when I am serializing my custom control, I am getting an exception "Ambigous Match Found". After debugging it, I found that it is throwing an exception due to the above custom ToolTip property (of type string), since there is already a ToolTip property present in FrameworkElement.

Is there any solution to this problem?

Upvotes: 0

Views: 274

Answers (1)

evpo
evpo

Reputation: 2531

you cannot override the ToolTip property. You have to give yours a different name.

Upvotes: 2

Related Questions