c# - Unhandled exception thrown by PhotoChooserTask -


i've got code , i'm using show button allows user choose image library , use background app.

so create photochoosertask, set show camera , bind method has executed when task completed. button start task showing photochoosertask. action on complete quite easy, i've got set boolean value , update image source.

photochoosertask pct_edit = new photochoosertask(); pct_edit.showcamera = true; pct_edit.completed += pct_edit_completed; button changeimagebutton = new button { content = "change image" }; changeimagebutton.tap += (s, e) => {     pct_edit.show(); };   void pct_edit_completed(object sender, photoresult e)     {         if (e.taskresult == taskresult.ok)         {             bi.setsource(e.chosenphoto);             isrebuildneeded = true;         }     } 

the problem won't show photochoosertask give me exception, taking me

private void application_unhandledexception(object sender, applicationunhandledexceptioneventargs e)     {         if (debugger.isattached)         {             debugger.break();         }     } 

in app.xaml.cs.

this looks weird i've got photochoosertask in same class , 1 works fine.

what's wrong it?

visualstudio won't tell me what's exception , there's no way figure out!

edit:

i found out exception thrown when call

pct_edit.show();  

in button's tap event.

you should defining chooser field in class. it's requirement have page scope photochooser. subscribe in constructor. stated on msdn here

class someclass {    readonly photochoosertask pct_edit = new photochoosertask();     someclass()    {        pct_edit.showcamera = true;        pct_edit .completed += new eventhandler<photoresult>(pct_edit_completed);    } } 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -