开发者

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 Fou开发者_StackOverflownd". 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜