20.5. Data Templates
Styles give you some basic formatting abilities, but they don't address the most significant limitation of the lists you've seen so far: no matter how you tweak the ListBoxItem, it's only a ListBoxItem, not a more capable combination of elements. And because each ListBoxItem supports just a single bound field (as set through the DisplayMemberPath property), there's no room to make a rich list that incorporates multiple fields or images.
However, WPF does have another tool that can break out of this rather limiting box, allowing you to use a combination of properties from the bound object and lay them out in a specific way or to display a visual representation that's more sophisticated than a simple string. That tool is the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access