0

When I define the margin width of my rectangle objects in WPF, they snap to the edge of the page, i.e. Margin="10,10,0,0" puts it in the top left corner instead of snapping to a 10,10 border around other objects. When I drag it to the correct place I want it to be, the margins end up with numbers like this: Margin="684,810,0,0"

It seems like the numbers are being set relative to the edges of my form, how can I fix this?

Darthmarshie
  • 87
  • 1
  • 11
  • I guess your parent Control is a `Grid`. You should probably read up on http://wpftutorial.net/LayoutProperties.html to learn how layout works in WPF – Viv Jun 10 '13 at 10:04
  • Awesome. Thanks for a quick, simple answer. I'll check it out. – Darthmarshie Jun 10 '13 at 10:12

1 Answers1

0

The Margin="10,10,0,0" says that your rectangle is 10 pixels right to the left most corner of the container. This happens when there is no other control in the parent container.

You should not worry about large number in margins because they are relative to the size of the parent container. If say Grid is the parent one of the height and width as 100 and 100 respectively, you cannot have large number as the margin.

Arushi Agrawal
  • 619
  • 3
  • 10
  • If I use x,y,0,0 and select the control in design mode, it will take space of the whole screen (can't select below control). How you handle that situation – Anirudha Gupta Jul 11 '18 at 06:50