0
Answer

Ambigous Match Found exception in WPF designer

jordan smith

jordan smith

13y
1.9k
1

Hi,

 

I have created a custom control in WPF. While working with that custom control in WPF designer, it is throwing Ambigous Match Found exception in designer. But if I create it in blend, it does not throw any exception and works fine. I tried investigating on the issue and found that I have a overridden dependency property in my custom control which is causing the problem. I have overridden control's BorderThickness property to Double (instead of Thickness) using new keyword as shown below.

 

Examnple:

public new Double BorderThickness
{
        get
        {
            return (Double)GetValue(BorderThicknessProperty);
        }
        set
        {
            SetValue(BorderThicknessProperty, value);
        }
}

 public new static readonly DependencyProperty BorderThicknessProperty = DependencyProperty.Register
            ("BorderThickness",
            typeof(Double),
            typeof(MyControl),
            new PropertyMetadata(0.25, null));

 

This I did because I want to bind BorderThickness property to Ellipse's StrokeThickness property. I don't want to create a custom property other than BorderThickness property, that's why I have overridden BorderThickness property in my custom control. Can anybody please tell me how to resolve the issue?