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.
Indicate control size
From the course: Windows Presentation Foundation: 2 Layout
Indicate control size
- [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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.