c# - Unobscured event gives NullReferenceException -


i trying add unobscured event root phoneapplicationframe this:

phoneapplicationframe rootframe = (phoneapplicationframe)app.current.rootvisual; rootframe.unobscured += new eventhandler((s, e) => { dosomething(); }); 

but when run windows phone 8 app gives me nullreferenceexception in second line of code sample. there other way this?

you need careful when access rootvisual may still null. example, null in main page constructor. rootvisual set in completeinitializephoneapplication method in app.cs file.


Comments

Popular posts from this blog

php - Dynamic url re-writing using htaccess -

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -