Solved: How to use one line per item in a UWP XAML ListView
Read the rest of entry »
The previous post outlined in an XAML UI using a ListView how to display a List of instances of a class of public properties using data binding. Layout and padding issues were examined as well as binding to a dictionary of objects. This article covers programmatically adding elements of a collection to an XAML UI.
I had a Dictionary of values that I wanted to display in an XAML UI as part of a UWP app. My initial foray was to use a ListView with a binding to the dictionary ListView.ItemTemplate/DataTemplate. The dictionary was then bound to the ListView’s ItemsSource. The problem with the ListView is that there is a lot of padding between items vertically and within items.I wanted to compact the rows of data vertically though as if I had manually placed each dictionary item (key and values) in a grid of rows of TextBlocks in a row (one row for each item). This article discusses my trials and tribulations with this issue and includes my final solution.