I fixed this, but I'm not 100% sure I understand how/why the solution I arrived at resolved my problem.
I fixed the problem by switching to using a Windows.Storage.Streams.IRandomAccessStream to read the file into the BitmapImage Source:
private async void addImageButton_Click(object sender, RoutedEventArgs e)
{
Windows.Storage.Pickers.FileOpenPicker filePicker = new Windows.Storage.Pickers.FileOpenPicker();
filePicker.SuggestedStartLocation = Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
filePicker.FileTypeFilter.Add(".jpg");
filePicker.FileTypeFilter.Add(".png");
filePicker.FileTypeFilter.Add(".bmp");
filePicker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
Windows.Storage.StorageFile imageFile = await filePicker.PickSingleFileAsync();
if (imageFile != null)
{
Windows.UI.Xaml.Media.Imaging.BitmapImage bitmap = new Windows.UI.Xaml.Media.Imaging.BitmapImage();
Windows.Storage.Streams.IRandomAccessStream stream = await imageFile.OpenAsync(Windows.Storage.FileAccessMode.Read);
Image newImage = new Image();
bitmap.SetSource(stream);
newImage.Source = bitmap;
newImage.Height = 250;
newImage.Stretch = Stretch.UniformToFill;
newImage.ManipulationMode = ManipulationModes.All;
newImage.ManipulationDelta += TestImage_ManipulationDelta;
this.theCanvas.Children.Add(newImage);
}
}
This resolved the issue and I can now load image files from any arbitrary location. However, I'm not 100% why this resolved the problem. I think it has something to do with async. I think that the way I was doing it before would somehow result in the BitmapImage or Image not containing the actual image data at display time. What I think this solution did was make the display code wait until we'd actually taken time to load the image. Even though this is solved, if a