From the course: XAML Fundamentals: Building Powerful UIs for Cross-Platform Applications

Unlock this course with a free trial

Join today to access over 24,900 courses taught by industry experts.

Make an item selectable with a ListBoxItem

Make an item selectable with a ListBoxItem

- [Instructor] Let's revisit some of the XAML we looked at earlier, a couple videos ago. This is the ListBox and it has several text blocks as children. Now, these are in here and the user, because it's in a ListBox, the user can select one of those items when the application's running, and then we can write code to determine which of the items they've selected. Now, think about this. The TextBlock class does not have the notion of selectability. Neither does the StackPanel that's a child of this ListBox, or the ellipse, so where does that come from? Well, that comes from some other classes. One of the classes is the selector class. That's the base class for ListBox. And this is where we can get properties like which items are selected. The other functionality comes from these classes over here. So the ListBox, every item that's added to the ListBox is actually wrapped in something called the ListBoxItem.…

Contents