Xamarin.Forms:ImageSource加载失败,仍然显示图像吗?

时间:2018-10-10 19:12:45

标签: xamarin xamarin.forms

我目前正在经历一种奇怪的行为:

private async void closeImageEditorWindow(string image)
        {
            await Navigation.PopAsync();
            var context = BindingContext as UserViewModel;
            ImageSource source = ImageSource.FromFile(image);
            context.UserAvatar = source;
            testUser.Source = source;
        }

代码接收图像的文件名,然后从该文件名中创建一个ImageSource。该ImageSource是a)在我的ViewModel中设置为属性,以及直接设置为Image控件的Source.Property(“ testUser”)。 UserAvatar属性也绑定到另一个Image控件。

因此,在控制台上,我两次收到以下消息(似乎对于每个Image控件)

[0:]无法加载名为{0}的图像:/storage/emulated/0/Pictures/Image20181010150448480.png

还是,两个图像控件都显示正确的图像?!(在指定的文件夹中)

为什么?我不确定控制台消息的来源,因为我没有stacktrace。

谢谢!

编辑:根据Xamarin.Forms Github的说法,这可能是记录此警告的Android ResourceManager.GetDrawable方法。在FileImageSource.LoadImageAsync方法中调用此方法。我还是不明白,为什么我能看到正确的图像,因为GetLogable在记录警告后返回null,而LoadImageAsync应该记录另一个警告...。我很困惑。

0 个答案:

没有答案
相关问题