我正在尝试将图片加载到我的 win8 应用程序的图像 UI 项中。但到目前为止,我无法让选择的图像显示在 UI 上。有人可以告诉我正确的做法吗?
Windows.Storage.Pickers.FileOpenPicker OpenPicker = new Windows.Storage.Pickers.FileOpenPicker();
OpenPicker.FileTypeFilter.Add(".jpg");
OpenPicker.FileTypeFilter.Add(".bmp");
Windows.Storage.StorageFile picture = await OpenPicker.PickSingleFileAsync();
imgPreview.Source = new Windows.UI.Xaml.Media.Imaging.BitmapImage(new Uri(picture.Path, UriKind.Absolute));
imgPreview.Stretch = Stretch.Fill;
imgPreview.Visibility = Windows.UI.Xaml.Visibility.Visible;