I am having this error when creating a new instance of MenuFlyout.I searched for a bit but couldn't find anything.Code is simple :
var tmpFlyout = new MenuFlyout();
I tried creating this instance from a different thread but that didn't help either , still got the exception.In which cases this exception will pop-up ?
Found this answer here
The problem is that your event handler doesn't execute on the UI thread. I think the best way to fix that is to convert your EAP (Event-based Asynchronous Pattern) method to TAP (Task-based Asynchronous Pattern) using TaskCompletionSource:
Maybe that helps you out
Dispatcher.RunAsync solved the problem.
I tried with Task.Run method but problem persisted.As suggested , I did with RunAsync and problem solved.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.