question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Using IMap/IObservableMap as ItemsSource for ListView

See original GitHub issue

Also 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:open
  • Created 4 years ago
  • Reactions:1
  • Comments:20 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
kennykerrcommented, Nov 16, 2019

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

1reaction
lawabidercommented, Jan 23, 2020

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: image

My XAML is: image

Also the changes (e.g. Clear()) don’t seem to be showing up on the UI.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF how to bind Item of ItemsSource in a ListView
So the item source is a list of Device objects and i want to bind the current device object to my customcontroll DependencyProperty....
Read more >
ListView Data Sources - Xamarin
ItemsSource. A ListView is populated with data using the ItemsSource property, which can accept any collection implementing IEnumerable .
Read more >
ListView.itemSource does not work with custom types.
I have a collection: List which I wanted to use as the source (as ListView just passes this to the Bind handler anyhow,...
Read more >
DataBinding | ListView for WPF | ComponentOne
The Data Binding feature in ListView control helps to update the data on the ListView UI by reducing the code size. The ItemsSource...
Read more >
False binding error in ListView when ItemsSource and ...
In the main view XAML, I have a ListView with its ItemsSource set to an ObservableCollection property in the view model. I have...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found