When a child element is smaller than the size of the containing panel, the panel decides how to align the content in the larger space. This video investigates the HorizontalAlignment and VerticalAlignment properties.
- [Instructor] In this video,…I'll look at how the HorizontalAlignment…and VerticalAlignment properties…affect the size of a child element.…Here's the example I'll start with.…It's on MainWindow.xaml…and I have a StackPanel…and I have a LetterBox…where I've hardcoded the width to 120 pixels.…When the width is hardcoded,…that's considered the desired width…and in this case,…I'm in a StackPanel,…and the StackPanel honors my desired width.…Now when you set the Width to Auto,…than the element falls back to its internal rules,…and in my case, for my LetterBox,…the internal rules are,…if you don't specify a height and width,…default back to 80 pixels in height and 80 pixels in width.…
Now if you look at LetterBox B over here,…you can see it's 80 pixels high…but it's more than 80 pixels in width,…so what's going on there?…Well here's what's going on.…When you specify HorizontalAlignment = Stretch,…or VerticalAlignment = Stretch,…you're granting permission to the panel…to change the final size.…So when you specify a hardcoded value, you get that value.…
- Exploring the layout panels
- Working with the grid
- Adding rows and columns
- Creating scrolling content
- Controlling element visibility
- Aligning content
- Making custom layout panels
Skill Level Intermediate
Learning Visual Studio Team Serviceswith Jose Miguel Rady Allende1h 17m Intermediate
1. Layout Panels
2. Other Layout Concepts
3. Custom Layout Panel
Next steps1m 34s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.