开发者

Overriding ToolTip in WPF

开发者 https://www.devze.com 2023-04-11 02:28 出处:网络
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

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

精彩评论

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