From the course: Windows Presentation Foundation: 2 Layout

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Work with margins

Work with margins

From the course: Windows Presentation Foundation: 2 Layout

Start my 1-month free trial

Work with margins

- [Instructor] In this video I'll look at the margin property. This is a way for an element to specify a buffer around the edges of the element. This means when you set the margin and the layout engine goes to arrange around the screen, if there's a margin present, the element will be positioned that distance away from it's nearest neighbor, also according to the layout rules of whatever panel that it's in. For this example I'm in a stack panel that has several letter boxes. All of these letter boxes are using the default margin which is a value of zero for all four sides. Here you can see on line 14 I've specified an explicit margin value, the rest of them are using an implicit value. Now, I'll switch over here and set the margin from B. This is a numeric value or a common delimited value. I'll start by using the simplest which is to set all four sides. I'll type in a number here of 10. What you see over in the Designer is that the stack panel pushed the letter box B down 10 pixels…

Contents