Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top