c# - System.AccessViolationException while setting DataContext in Windows Store App -
i navigate new page , on page set datacontext
on page load event.
public mypage() { this.initializecomponent(); this.loaded += mypage_loaded; } void mypage_loaded(object sender, routedeventargs e) { this.datacontext= mymodel; }
while setting data context, lot of times system.accessviolation
exception , application quits.
what problem?
edit
i tried following
1) set navigationcachemode
disabled
2) made page basic page i.e. remove inheriting layoutawarepage
i still getting exception
you must ensure data ui binds changed ui thread. can like
public static async task runonuithread(dispatchedhandler action) { await coreapplication.mainview.corewindow.dispatcher.runasync(coredispatcherpriority.normal, action); }
Comments
Post a Comment