Reputation: 3443
I am totally new to Xamarin, and now want to use vectorgrahpics in my xamarin.forms application. In order to do so, I right clicked on the Solution > Mange NuGet Packages for Solution > Install Xamarin.FFImageLoading.Svg.Forms
Then I used this code:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="SMSIP_Xamarin.FileBrowser"
Title="File Browser">
<ListView x:Name="listView" RowHeight="60" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View >
<StackLayout Orientation="Horizontal" Margin="8,8,8,8">
<ffimageloadingsvg:SvgCachedImage WidthRequest="50" HeightRequest="50" Source="{Binding IconSource}"/>
<StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" Margin="6,0,0,0">
<Label Text="{Binding FileName}" HorizontalOptions="FillAndExpand" Margin="0,0,0,-5" FontSize="18" TextColor="Black"/>
<Label Text="{Binding Size}" FontSize="12" TextColor="Gray" Margin="3,0,0,0"/>
</StackLayout>
<Switch IsToggled="{Binding DoSynchronization}"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
No I get the error
"ffimageloadingsvg" is an undeclared prefix.
What am I doing wrong?
Upvotes: 0
Views: 640
Reputation: 2981
You need to add a namespace declaration for ffimageloadingsvg on the top of the page:
xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
So it looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms"
x:Class="SMSIP_Xamarin.FileBrowser"
Title="File Browser">
<ListView x:Name="listView" RowHeight="60" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View >
<StackLayout Orientation="Horizontal" Margin="8,8,8,8">
<ffimageloadingsvg:SvgCachedImage WidthRequest="50" HeightRequest="50" Source="{Binding IconSource}"/>
<StackLayout Orientation="Vertical" HorizontalOptions="StartAndExpand" Margin="6,0,0,0">
<Label Text="{Binding FileName}" HorizontalOptions="FillAndExpand" Margin="0,0,0,-5" FontSize="18" TextColor="Black"/>
<Label Text="{Binding Size}" FontSize="12" TextColor="Gray" Margin="3,0,0,0"/>
</StackLayout>
<Switch IsToggled="{Binding DoSynchronization}"/>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ContentPage>
Upvotes: 1