简体   繁体   中英

XAML reference not set to instance of object debugging with Xamarin Forms

I am builidng a XAML UI, with Xamarin.Forms, using this nuget plugin. I have followed the guide and have the following layout:

   <Grid VerticalOptions="Center" HorizontalOptions="Center" BackgroundColor="#3DBEAF" >
   <Grid.RowDefinitions>
       <RowDefinition Height="10" />
       <RowDefinition Height="Auto" /> 
   </Grid.RowDefinitions>
   <Grid.ColumnDefinitions>
    <ColumnDefinition Width="10" />
    <ColumnDefinition Width="Auto" />
  </Grid.ColumnDefinitions>
  <abstractions:SvgImage Grid.Row="0" Grid.Column="0" SvgAssembly="{Binding SvgAssembly}" SvgPath="{Binding Logo_Round}" HeightRequest="50" WidthRequest="50" BackgroundColor="White" HorizontalOptions="Center" VerticalOptions="Center"/>
   </Grid>

I have followed the guide. I don't really see whats happening with the SvgAssembly="{Binding SvgAssembly}" line, or whether I need to update this? I have followed the sample app's form, by putting my resources in the main PCL project, in an images folder. I have set the build action for these resources, and also initialised the nuget across the platform specific projects as specified.

System.NullReferenceException: Object reference not set to an instance of an object at SVG.Forms.Plugin.iOS.SvgImageRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs`1 e) [0x00028] in :0

What have I done wrong / how can I debug further?

You are binding to SvgAssembly, so you need that defined in your ViewModel. The sample app defines it like this:

public Assembly SvgAssembly
{
    get { return typeof (App).GetTypeInfo().Assembly; }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM