0

我正在尝试将图片加载到我的 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;
4

1 回答 1

1

在这里查看我的帖子。

它应该是这样的:

xml:

<Image Margin="5" Source="{Binding BMImage}" Height="100"/>

C#:

BitmapImage bmImage;
public BitmapImage BMImage
{
    get
    {
        return bmImage;
    }
}

bmImage = new BitmapImage();

bmImage.UriSource = new Uri(new Uri(
     Windows.Storage.ApplicationData.Current.TemporaryFolder.Path + "\\" +
     Windows.Storage.ApplicationData.Current.TemporaryFolder.Name), 
     "favicon.scale-100.ico");
于 2012-12-18T16:03:29.473 回答