我正在使用Xamarin.FFImageLoading.Svg.Forms Nuget 包。
我的 XAML 中有图像绑定,我使用 ListView.ItemTemplate 一次呈现多个菜单项。
<ffimageloadingsvg:SvgCachedImage
WidthRequest="50"
HeightRequest="50"
Source="{Binding ImageSource}"/>
以及一个包含 SVG 路径数据的 ViewModel。如您所见,我尝试了几种方法(出于测试目的而注释最多),它们都失败了。
MenuItems = new ObservableCollection<MenuItem>(new[]
{
new MenuItem { Id = 1,
Title = "Facility Info",
CommandParameters = "",
ImageSource = Xamarin.Forms.ImageSource.FromResource("myMTC.Assets.Images.user.svg") },
//new MenuItem { Id = 2,
// Title = "Workshops",
// CommandParameters = "",
// ImageSource = SVG_ASSET_PATH + "user.svg" },
//new MenuItem { Id = 3,
// Title = "Feedback",
// CommandParameters = "",
// ImageSource = Xamarin.Forms.ImageSource.FromResource("myMTC.Assets.Images.user.svg") },
//new MenuItem { Id = 4,
// Title = "Artifacts",
// CommandParameters = "",
// ImageSource = Xamarin.Forms.ImageSource.FromFile("ms-appx:///Assets/Images/user.svg") },
//new MenuItem { Id = 4,
// Title = "Action Items",
// CommandParameters = "",
// ImageSource = new Uri(SVG_ASSET_PATH + "Droid.saction-items.svg") },
});
似乎错误植根于ImagerLoaderTask API中的某处
ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:463
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <401c12b575cb4781b0a9e010ed5a0221>:0
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <401c12b575cb4781b0a9e010ed5a0221>:0
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <401c12b575cb4781b0a9e010ed5a0221>:0
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <401c12b575cb4781b0a9e010ed5a0221>:0
08-23 14:41:49.328 I/mono-stdout( 5366): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <401c12b575cb4781b0a9e010ed5a0221>:0
08-23 14:41:49.328 I/mono-stdout( 5366): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <401c12b575cb4781b0a9e010ed5a0221>:0
08-23 14:41:49.328 I/mono-stdout( 5366): at FFImageLoading.Work.ImageLoaderTask`2+<RunAsync>d__109[TImageContainer,TImageView].MoveNext () [0x00435] in C:\projects\ffimageloading\source\FFImageLoading.Common\Work\ImageLoaderTask.cs:463
运行 FFImageLoading
发布> 2.2.10-pre-428
.
VS2017 Enterprise(有时也使用预览版)
在 Windows 10 Enterprise v1703 OS Build 15063.540 64 位