
We learned about two types of panels in WPF: StackPanel and DockPanel. The StackPanel will position each of its child controls next to the other, horizontally (default) or vertically, until there is no more room and then it simply expands itself, if possible. the child controls are stretched to take up the full width or height (based on the largest item). Use the StackPanel when you want a list of controls that takes up all the available room, without wrapping. The DockPanel allows you to dock the child controls to the top, bottom, left or right. By default, the last control, if not given a specific dock position, will fill the remaining space. Use the DockPanel whenever you need to dock one or several controls to one of the side. We explored a font-viewer application which allows the user to select a specific font from a list and modify the text accordingly. the text could be modified by the user and is automatically duplicated among all other text blocks. the entire application is written without a single line of code! only in XAML declarations! we saw how the { } brackets are used to compute a value in XAML – for example to read a list of fonts, set a font value , set a text value etc. we also saw some more cool design features such as : margin, padding, border, background colors and more
More topics covered:
- What is XML ?
- Create multiple XAML windows inside the application
- Binding data to Control
- Margin orientation – single value, two values, etc.
- Border control
- Nesting panels – panel inside a panel
- ListBox – ItemsSource, SelectedItem
- Path attribute
- x: [name-of-property]
- Adding ToolTip
- TextBlock is more lightweight control for displaying text
- TextBox is used when you require user input or edit existing text
- TextWrapping attribute
- MinLines attribute
Links:
- Class code: Font Viewer
- Class code: Exercise solution
- WPF panels – nice article
- Binding data to control – nice article
- Margin vs Padding vs Border – CSS example
- Home Work!
- Lesson Summary Video!
