0
private ImageSource _image = null;
    private String _imagePath = null;

    public ImageSource Image
    {
        get
        {
            if (this._image == null && this._imagePath != null)
            {
                //this._image = new BitmapImage(new Uri(VMDataCommon._baseUri, this._imagePath));

                this.LoadImages();
            }
            return this._image;
        }

        set
        {
            this._imagePath = null;
            this.SetProperty(ref this._image, value);
        }
    }

    private async void LoadImages()
    {
        Windows.Storage.StorageFile imageFile = await Windows.Storage.KnownFolders.PicturesLibrary.GetFileAsync(_imagePath);

        BitmapImage img = new BitmapImage();

        FileRandomAccessStream stream = (FileRandomAccessStream)await imageFile.OpenAsync(FileAccessMode.Read);

        img.SetSource(stream);

        //img = await LoadImage(imageFile);
        this._image = img;
        //return this._image;
    }

这是我用来检索图片文件夹中的图像的方法。但我不知道为什么当我运行应用程序时有时它不显示,有时它显示。谢谢。

4

0 回答 0