views:

545

answers:

1

Let's say I want to position an element at the coordinates x=20, y=5 within the 3rd column of a Grid control. How do I do this? Do I need to add a Canvas panel to the column and then add the controls to it?

Thanks.

+2  A: 

You can do it that way, but have a look at this.. Attached Property

<Grid Background="Yellow">
  <Rectangle Fill="Red" Margin="20,10,0,0" Width="50" Height="30"
     HorizontalAlignment="Left" VerticalAlignment="Top" />
  <Rectangle Stroke="Green" Margin="30,15,0,0" Width="20" Height="30"
     HorizontalAlignment="Left" VerticalAlignment="Top" />
</Grid>

You can use the Margin property to simulate absolute positioning.

Not sure whether this would help you, but in any case an interesting read.

rajesh pillai
It worked perfectly, thanks :)
Trap