Windows Phone: How to retrieve the same photo from media library between application instances

若如初见. 提交于 2019-12-04 18:06:33

I found the answer in the documentation: http://msdn.microsoft.com/en-us/library/gg680264%28v=pandp.11%29.aspx Basically, there is a bug in the photo chooser which returns a temporary path. Microsofts recommendation is to copy the picture to isolated storage if you want to use it between app instances.

Application.GetResourceStream will return null for that path because the GetResourceStream method is looking for a resource within the application itself, not from the device.

To re-load the same image on resume from tombstoning simply persist the OriginalFileName property, and then use that to create a BitmapImage as follows:

string path = /* Load the saved OriginalFileName */;
var bitmap = new BitmapImage(new Uri(path, UriKind.Absolute));
myImageControl.Source = bitmap;

NOTE: The OriginalFileName property is already a string, so you don't need to call .ToString() on it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!