Using IMap/IObservableMap as ItemsSource for ListView
See original GitHub issueAlso posted here.
I’ve described the problem on StackOverflow already and also filed a docs issue before finding out that the docs are actually technically right.
To summarize, I can bind an IVector<T> to a ListView control just fine, but when I substitute it with an IMap<K,V> or IObservableMap<K,V> I get exceptions. As I’ve found out this is due to IMap<K,V> not implementing IIterable<IInspectable> which is what the ItemsSource property expects.
However, it is possible to use Dictionary in C# and everything works just fine, so there must be something else happening here. Do you know how to CLR handles this and how I can accomplish this in C++?
Steps to reproduce the bug
- Create a XAML ListView and bind an IMap<K, V> to ItemsSource property using x:Bind
Expected behavior The ListView shows key-value pairs the same way as when using a Dictionary in C#
Version Info
| Windows 10 version | Saw the problem? |
|---|---|
| 18363.476 | Yes |
| Device form factor | Saw the problem? |
|---|---|
| Desktop | Yes |
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:20 (8 by maintainers)

Top Related StackOverflow Question
Here is a simple implementation that implements
IIterable<IInspectable>, as has been suggested by the Xaml team. If someone can test this against Xaml and confirm that this provides the desired behavior then we can update C++/WinRT to do the same.https://gist.github.com/kennykerr/6eace7378a1a06b5e2f21da127be102a
Has anyone been able to display the Key and Value in a ListView? I’m not sure if my XAML is correct. I can only get a stringification of the KeyValuePair:
My XAML is:
Also the changes (e.g. Clear()) don’t seem to be showing up on the UI.