Setting an element's size appears to be a simple task in WPF development. After all, every UI element has a Width and Height property. Modern apps need to be flexible and adjust to changing screen sizes and other factors. See how using autosize is a better option.
- [Narrator] Each control sets its desired size…during the two-phase layout.…You can affect the desired size…with setting a number of properties.…The most obvious properties to set are the width…and height properties.…Let's take a look where you find those.…In WPF, there's a class called FrameworkElement…that's a base class for a lot of the UI elements…that you work with.…And if you look at its properties,…you'll see that it has a height and has a width property.…That means that a lot of the elements…that you work with will have those properties.…
For example, the TextBlock derives from FrameworkElement.…So does the Ellipse class,…and so does the Button class.…Let's see how you would set those.…Go to MainWindow.xaml.…And here's an example.…I've got a canvas that contains an ellipse.…And I've specified a width and a height property here,…40 pixels and 60 pixels.…That's the desired size when it goes to the layout phase.…In this case, the canvas leaves…the desired size alone and the ellipses are drawn…at the desired size.…
- 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.