Forum Xamarin Cross Platform with Xamarin

What's wrong with my XAML for TabbedPage?

So for my first Xamarin Project, I've decided to make a simple UI using Xamarin.Forms PCL. My first goal is to make the first page open to a TabbedPage, but it keeps crashing in Android tablets (but not Windows). The TabbedPage is the first page called by public App().

        public App()
            // The root page of your application
            MainPage = new UI.TabsTester();

Where UI.TabsTester is

<?xml version="1.0" encoding="utf-8" ?>
<TabbedPage xmlns=""
            Title ="Thar be Tabs">

The children tabs are regular content pages with just a title and some text. They all work when I call them in as MainPage in public App().

When I run this code in a Windows 8 Tablet Simulator, it works fine. The problem is when I run it in an Android Emulator, it crashes! After searching the internet for a solution, I decided to try writing the TabsTester in C#.

        public TabsTester2()
            this.Title = "Hello!";
            this.Children.Add(new Tabs.Page1());
            this.Children.Add(new Tabs.Page2());
            this.Children.Add(new Tabs.Page3());

And now it works in both Windows and Android. So what's wrong with my XAML?

Best Answer


  • MartinWangMartinWang USMember
    edited June 2015

    Quick update: my coworker also ran into a similar issue regarding ListView. When the page and view are formatted in XAML, it works on Windows but crashes on Android. Then when he swaps all the code into C#, it works on both. I'll grab his code if anyone's interested.

    Meta comment: the preview button on this forums didn't get replaced by an edit button when I was previewing and editing my opening post, but it's working for this response. Using latest chrome.

    Edit; Thanks Esteban, I'll try that out!

  • MartinWangMartinWang USMember

    Hi @stvansolano,

    The assembly suggestion was right on track! I used assembly=MyProject and now it works fine.

  • stvansolanostvansolano UMInsider, University ✭✭✭

    Awesome @MartinWang! Happy coding

Sign In or Register to comment.