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.
Replace layout panel in ListBox
From the course: Windows Presentation Foundation: 2 Layout
Replace layout panel in ListBox
- [Narrator] One of my favorite features of WPF is the idea of a template. A template allows me to take some UI, let's say a control UI or some data, and I can specify a set of WPF elements, put them inside a template, and then I can tell WPF to use the template to render the data or the template to replace the default UI for a control template. And what I'm showing you in this example is how to replace the layout panel that's part of a listbox. In this example, I have a window with a listbox named VegetableListBox which contains a number of TextBlocks. And then I have a button and an empty TextBlock here. And the idea is that when you click on the button we'll find out whether there's anything selected in the listbox, and if so, I'll output the text in the listbox. So, it looks like this. Pick the item, click on the button, and it shows the results here. Let's pick another item, click on the button. So that's the basics, a really simple application. Now here's the thing about 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.