Search code examples
androidxamarinxamarin.formsxamlparseexception

Xamarin Forms - XAML ContentPage error "No Property of name Id found"


So I'm trying to get this app off the ground so I can actually start putting functionality in it and it's failing to load the first page.

I'm getting a XamlParseException when it attempts to LoadFromXaml in the generated class.

Error message is "No Property of name Id found"

public partial class ProxDefaultPage : ContentPage {//This is a generated class

    private ActivityIndicator Discoverying;

    private void InitializeComponent() {
        this.LoadFromXaml(typeof(ProxDefaultPage));//error thrown here
        Discoverying = this.FindByName<ActivityIndicator>("Discoverying");
    }
}

Here's the XAML markup of the page in question

<?xml version="1.0" encoding="UTF-8"?>
<ContentPage
    Id     ="cpDiscovery"
    x:Name ="Discovery"
    xmlns ="http://xamarin.com/schemas/2014/forms"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    x:Class="MyApp.Droid.DefaultPage">
        <ActivityIndicator
            Id       ="aiDiscovering"
            IsRunning="true"
            Color    ="Blue"
            x:Name   ="Discoverying" />
</ContentPage>

What am I missing in the markup that isn't getting parsed?


Solution

  • After a quick run to the Xamarin forums, I got an answer.

    http://forums.xamarin.com/discussion/32014/cant-load-basic-contentpage-xamlparseexception-no-property-of-name-id-found

    Turns out, the generated class does not use a property named "Id", or the property named "Id" does not match the type of data provided. Having this attribute in the xaml markup caused the error.

    By removing the Id attribute from the ContentPage, the page finally ran successfully.