How to set a picked image as background of a grid dynamically, save it in app local storage and retrieve it each time app is launched?
BitmapImage BgBitmap = new BitmapImage();
Image BgImg = new Image();
private async void bgbtn_Click(object sender, RoutedEventArgs e)
{
var fop = new FileOpenPicker();
fop.SuggestedStartLocation = PickerLocationId.PicturesLibrary;
fop.FileTypeFilter.Add(".jpg");
fop.FileTypeFilter.Add(".png");
fop.CommitButtonText = "OK";
fop.ViewMode = PickerViewMode.Thumbnail;
StorageFile file = await fop.PickSingleFileAsync();
IRandomAccessStream stream= await file.OpenAsync(FileAccessMode.ReadWrite);
await file.CopyAsync(ApplicationData.Current.LocalFolder, "BackgroundImg", NameCollisionOption.ReplaceExisting);
await BgBitmap.SetSourceAsync(stream);
BgImg.Source = BgBitmap;
}
Now, how to set this BgImg as "mainGrid" Grid Background? and it will be nice if i can save the picked file in app storage and set tht file as background.