Adjusting the Left,Top property of the Canvas from the code behind
If you want to move an UI object that is placed inside a Canvas. You may use any of the code below. Canvas.Left, etc being a attached property cannot be accessed from the codebehind directly
Canvas.SetLeft(myObject, 50)
or
myObject.SetValue(Canvas.LeftProperty, 50d); // make sure the second parameter is a double else it will throw an exception .
In the above examples myObject is your UI element you placed inside your canvas. eg:- Image, label,etc.
Canvas.SetLeft(myObject, 50)
or
myObject.SetValue(Canvas.LeftProperty, 50d); // make sure the second parameter is a double else it will throw an exception .
In the above examples myObject is your UI element you placed inside your canvas. eg:- Image, label,etc.
Comments