0

I'm using the Xamarin.FFImageLoading.Svg.Forms Nuget package.

I have the Image Bindings in my XAML where I'm using a ListView.ItemTemplate to render multiple menu items at once.

<ffimageloadingsvg:SvgCachedImage 
 WidthRequest="50" 
 HeightRequest="50" 
 Source="{Binding ImageSource}"/>

And a ViewModel containing the path data for the SVGs. I've tried several approaches as you can see (commented most out for testing purposes) and they all fail .

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") },
            });

It appears the error is rooted somewhere in the 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

Running FFImageLoading release > 2.2.10-pre-428.

VS2017 Enterprise (using preview sometimes too)

on Windows 10 Enterprise v1703 OS Build 15063.540 64 bit

SushiHangover
  • 73,120
  • 10
  • 106
  • 165
greg
  • 1,118
  • 1
  • 20
  • 40

1 Answers1

0

I had the same issue and was able to get it to work by putting the svg in the Drawables folder, setting it to AndroidResource, then referencing it directly by file name like so:

MenuItems = new ObservableCollection<MenuItem>(new[]
{                   
     new MenuItem { Id = 1,
                Title = "Facility Info",
                CommandParameters = "",
                ImageSource = "user.svg" }
}
Bryce
  • 45
  • 1
  • 7