c# - setting picture in image UI element using file picker -


in app user can set profile pic device memory i.e tablet memory or desktop local drive , upload server. used file picker user can select 1 picture , set profile picture, problem picture not sticking image element. code:

 private async void filepicker()         {             fileopenpicker openpicker = new fileopenpicker();             openpicker.viewmode = pickerviewmode.thumbnail;             openpicker.suggestedstartlocation = pickerlocationid.pictureslibrary;             openpicker.filetypefilter.add(".jpg");             openpicker.filetypefilter.add(".jpeg");             openpicker.filetypefilter.add(".png");              storagefile file = await openpicker.picksinglefileasync();             if (file != null)             {                  string filepath = file.path;                 system.diagnostics.debug.writeline(filepath);                  uri uri = new uri(filepath, urikind.relative);                 profilepicture.source = new bitmapimage(uri);             }         }          internal bool ensureunsnapped()         {             // filepicker apis not work if application in snapped state.             // if app wants show filepicker while snapped, must attempt unsnap first             bool unsnapped = ((applicationview.value != applicationviewstate.snapped) || applicationview.tryunsnap());             if (!unsnapped)             {                 //notifyuser("cannot unsnap sample.", notifytype.statusmessage);             }              return unsnapped;         } 

the file path i'm getting one

filepath=c:\users\prateek\pictures\img_0137.jpg 

i don't know went wrong.

i not sure if solve problem, did set image source.

using bitmap image source image

bitmapimage bitmapimage = new bitmapimage(); storagefile file = await openpicker.picksinglefileasync(); var stream = await file.openasync(windows.storage.fileaccessmode.read); await image.setsourceasync(stream); profilepicture.source = bitmapimage; 

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 -