Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 91519

XamSvg in MVVM

$
0
0

I just added the package to my PCL project, placed all the images on the svg images folder in PCL project, but I get the error on my xaml, can anyone help me to fix this issue.
Note: I am using the free edition of XamSvg

Package installed:
Install-Package Softlion.XamSvg.Free

Xaml Command Used:
'"svg:SvgImage Svg="res:images.sampleicon" HorizontalOptions="Center" HeightRequest="20"
Clicked="OnSvgClicked" ClickedCommand="{Binding SvgClickedCommand}"
ColorMappingSelected="ffffff=00ff00" /"'

Error:
Error:'svg' is an undeclared prefix. Line 14, position 12.
Error:Namespace prefix 'svg' is not defined.

Second approach:
added xmlns:controls="clr-namespace:XamSvg.Shared;assembly=XamSvg.Shared" to the contentPage tag and used the below code in XAML
"'controls:SvgImage Svg="res:images.sampleicon" HorizontalOptions="Center" HeightRequest="20"
Clicked="OnSvgClicked" ClickedCommand="{Binding SvgClickedCommand}"
ColorMappingSelected="ffffff=00ff00" /"'

The above code throws this error and crashes the app:
01-18 14:59:04.421 I/MonoDroid( 2621): UNHANDLED EXCEPTION:
01-18 14:59:04.422 I/MonoDroid( 2621): Xamarin.Forms.Xaml.XamlParseException: Position 14:12. Type controls:SvgImage not found in xmlns clr-namespace:XamSvg.Shared;assembly=XamSvg.Shared
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.XamlParser.GetElementType (Xamarin.Forms.Xaml.XmlType xmlType, IXmlLineInfo xmlInfo) [0x0027f] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, INode parentNode) [0x00014] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x0008b] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00062] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00062] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.ElementNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x0002b] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.RootNode.Accept (IXamlNodeVisitor visitor, INode parentNode) [0x00062] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.String xaml) [0x00097] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.XamlLoader.Load (Xamarin.Forms.BindableObject view, System.Type callingType) [0x0002b] in :0
01-18 14:59:04.422 I/MonoDroid( 2621): at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TView] (Xamarin.Forms.Xaml.TView view, System.Type callingType) [0x00000] in :0


Viewing all articles
Browse latest Browse all 91519

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>