Different thread exception when trying to set IPropertyNotifyChanged using MVVM Light from a secondary window

1

I'm using MVVM-Light with Windows Template Studio. My app works fine but when i open a view/viewmodel in a separate windows using WTS's WindowManagerService it gives me this error:

"System.Exception: 'The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))'"

I've fixed this in the past using my own InotifyBase and wrapping it in a coredispatcher but I can't do that with MVVM-Lights INotify implementation... I've tried variations of what's below but nothing works. I would think a ton of people are doing this but i can't find anything and anything I have found was vague or incomplete.

private bool _masterCollapse;
public bool MasterCollapse
{
    get { return _masterCollapse; }
    set
    {
        DispatcherHelper.UIDispatcher.RunAsync(CoreDispatcherPriority.Normal,() => Set(ref _masterCollapse, value));
    }
}
c#
uwp
mvvm-light
windows-template-studio
asked on Stack Overflow Mar 31, 2018 by beatnikthedan

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0