views:

400

answers:

3

In Flash this question is answered really easy because you can set the X and Y coordinates of an object:

newxpos = object._x;
newypos = object._y;

How do you do the same in Silverlight?

+7  A: 

Place the object inside a canvas element and then use:

Canvas.SetLeft(object, value);
Canvas.SetTop(object, value);
Spencer Ruport
Thanks Spencer. It worked like a charm.
Ry
A: 

The Canvas works if you want fixed positions. If you want relative positions or positions that are controlled in a more dynamic manner, you want to look into putting your controls inside a StackPanel or a FlowPanel or a WrapPanel, etc.

Kevin Hoffman
A: 

Canvas.SetLeft(object, value); is a good feature but if you control changes ownership dynamically it's better to target the control itself with "yourcontrolname".SetValue(Canvas.LeftProperty, value);