The following forum(s) have migrated to Microsoft Q&A (Preview): Developing Universal Windows apps!
Visit Microsoft Q&A (Preview) to post new questions.

Learn More

Photo Chooser RRS feed

  • General discussion

  • Hi

    I am un=sing the photoChooserTask to allow auser to select a photo to use as their prefrerd background my problem is how to save and reloa the selected value using isolated storage via XmlSerializer?

    this is my sample code.. e.OriginalFileName does give me a file name and path but it does not seem to work using SettingBackground.Source = new BitmapImage(new Uri(MainPage.Settings.UserBackground)); can anyone tell me the best way to get this to work?

    private void bnCustomBk_Click(object sender, RoutedEventArgs e)  
            void photoChooserTask_Completed(object sender, PhotoResult e)  
                if (e.TaskResult == TaskResult.OK)  
                    BitmapImage image = new BitmapImage();  
                    SettingBackground.Source = image;  
                    MainPage.Settings.UserBackground = e.OriginalFileName;  
                    MainPage.Settings.UserBackgroundEnabled = "T";  
    Wednesday, February 23, 2011 1:57 AM

All replies

  • Save the bitmap to IsolatedStorage and reload it from there.
    Wednesday, February 23, 2011 4:38 AM
  • How do you save the bitmap to isolated storage?
    Friday, April 22, 2011 4:19 PM
  • How do you save the bitmap to isolated storage?

    here is how to store and reload from storage.
    var wb = new WriteableBitmap(image);  
                        using (var isoFileStream = isoStore.CreateFile("yourbackground.jpg"))  
                            var width = wb.PixelWidth;  
                            var height = wb.PixelHeight;  
                            Extensions.SaveJpeg(wb, isoFileStream, width, height, 0, 100);  
    using (var isoStore = IsolatedStorageFile.GetUserStoreForApplication())  
                        using (var isoFileStream = isoStore.OpenFile("yourimage", FileMode.Open, FileAccess.Read))  
                            YourBackgroundImage = new BitmapImage();  
    Saturday, April 23, 2011 9:33 PM