App
App

Reputation: 356

can I create a simple dependency property to bind Margin?

I have a custom control and want to bind a user defined margin. In the client code where I try to use it, it shows an error. It says -

"'0}'string cannot be converted to Length"

 public static readonly DependencyProperty MarginProperty =
         DependencyProperty.Register("Margin", typeof (Thickness), typeof 
 (TestControl), new PropertyMetadata(default(Thickness)));

    public Thickness Margin
     {
         get { return (Thickness) GetValue(MarginProperty); }
         set { SetValue(MarginProperty, value); }
     }

Is there any issue with my dependency property?

Thanks & Regads

Upvotes: 0

Views: 687

Answers (1)

mechanic
mechanic

Reputation: 781

There is a Margin`property of any FrameworkElement already, what are you trying to achieve creating a dep property with the same name and same type?

Upvotes: 1

Related Questions