-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I'm having trouble binding to an IObservableMap instead of an IObservableVector, which works fine.
Binding to a single element of the map with indexer syntax in XAML works fine as well, but when I try to bind to the entire collection, I get HRESULT: 0x80070057 (E_INVALIDARG) when the ItemsSource property is set on load.
The documentation is contradictory here; the ItemsSource property page says:
The ItemsSource property value must implement one of these interfaces:
IIterable<IInspectable>
IBindableIterable
and according to C++/WinRT headers, IObservableMap<K, V> implements IIterable<IKeyValuePair<K, V>>, where IKeyValuePair<K, V> is an IInspectable, yet it doesn't work.
On the other hand the C++/WinRT collection docs say:
If you want to bind a XAML items control to your collection, then you can.
But be aware that to correctly set the ItemsControl.ItemsSource property, you need to set it to a value of type IVector of IInspectable (or of an interoperability type such as IBindableObservableVector).
According to my experience so far, the C++/WinRT docs are right and the other page should be corrected.
On the other hand, I've tried doing the same with a C# Dictionary and it worked without a problem. I know the CLR is doing a lot of interop magic, but this shows me that it's indeed possible to bind to a map, so what exactly is going on there?