I have a TreeView XAML control. I am data binding it to a Vector with a property:
property Windows::Foundation::Collections::IObservableVector<TreeViewData^>^ Items
{
Windows::Foundation::Collections::IObservableVector<TreeViewData^>^ get() { return _containerItems; }
}
If I append to the vector out of the lambda for my async op, it is fine. If I append in the lambda, I get this error:
Exception thrown at 0x00007FF8E8845419 in DevicePanels.exe: Microsoft C++ exception: Platform::InvalidCastException ^ at memory location 0x0000001011AFE5A0. HRESULT:0x80004002 No such interface supported WinRT information: No such interface supported
// this works
_containerItems->Append(ref new TreeViewData());
_handlerAdded = ref new TypedEventHandler<DeviceWatcher^, DeviceInformation^>(
[this](DeviceWatcher^ sender, DeviceInformation^ deviceInfo)
{
Dispatcher->RunAsync(CoreDispatcherPriority::Low, ref new DispatchedHandler(
[this, deviceInfo]()
{
// this does not work
_containerItems->Append(ref new TreeViewData(deviceInfo));
It seems like the main difference would be related to what thread the append is running on, but the error code is E_NOINTERFACE
Any suggestion?
User contributions licensed under CC BY-SA 3.0