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

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -