Change Canvas.Left property in code behind?

Try this

theObject.SetValue(Canvas.LeftProperty, 50d);

There is a group of methods on DependencyObject (base of most WPF classes) which allow the common access to all dependency properties. They are

  • SetValue
  • GetValue
  • ClearValue

Edit Updated the set to use a double literal since the target type is a double.


As we are changing the property of the 'object', it would be better to use method suggedte by JaredPar:

theObject.SetValue(Canvas.LeftProperty, 50d);

Canvas.SetLeft(theObject, 50)