2017-09-13 37 views
0

我对Xamarin是全新的,现在想在我的xamarin.forms应用程序中使用vectorgrahpics。 为了做到这一点,我右击的解决方案>疥癣的NuGet包解决方案>安装Xamarin.FFImageLoading.Svg.FormsXamarin:使用NuGet FFImageLoading.Svg.Forms

然后我用这个代码:

<?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> 

不,我得到的错误

“ffimageloadingsvg”是一个未声明的前缀。

我在做什么错?

回答

1

你需要在页面的顶部添加空间声明ffimageloadingsvg:

xmlns:ffimageloadingsvg="clr-namespace:FFImageLoading.Svg.Forms;assembly=FFImageLoading.Svg.Forms" 

所以它看起来像这样:

<?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> 
+0

由于它的工作,你能回答我一个小的后续up问题:我在哪里可以找到正确的namespae来设置,那么为什么要正确地使用ffimageloadingsvg =“clr-namespace:FFImageLoading.Svg.Forms; assembly = FFImageLoading.Svg.Forms”? –

+1

大多数软件包在它们的文档中指定它https://github.com/luberda-molinet/FFImageLoading/wiki/SVG-support - 但它的引用程序集的程序集名称和您需要的控件的名称空间驻留在其中。 –

相关问题