我目前正在经历一种奇怪的行为:
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控件 .
所以在控制台上,我收到两次以下消息(貌似每个图像控件)
[0:] Could not load image named: {0}: /storage/emulated/0/Pictures/Image20181010150448480.png
仍然, both Image controls show the correct image?! (它存在于指定的文件夹中)
为什么?我不确定控制台消息的来源,因为我没有堆栈跟踪 .
提前致谢!
编辑:根据Xamarin.Forms Github,这可能是记录此警告的Android ResourceManager.GetDrawable方法 . 这个是在FileImageSource.LoadImageAsync方法中调用的 . 我仍然不明白,为什么我看到正确的图像,因为GetDrawable在记录警告后返回null,而LoadImageAsync应该记录另一个警告...我很困惑 .