Tip: Creating a New Xamarin XAML Page

I decided to write this quick post because I ran into a silly problem that took me about 45 minutes to figure out. I hope this saves you some time!

When you’re ready to create a new Page in a Xamarin Forms, app you’d the think the process was as easy as Right-Clicking the Shared Project, clicking “Add”, and selecting a page. Well, this is both right and wrong, as there’s a quick hurdle that can catch you the way it caught me.

Creating a Page

It can be very simple. Right click the Shared Project, and click “Add”-> “New Item”

1

Simple enough. Next step is to select which Item you want to add. Common sense dictates that since you want to add a XAML page, you’d head into the XAML section. Don’t do it! Those XAML templates are for Widows Apps only. Why it’s in the “Add New Item” dialog for a Xamarin app is beyond me, but we want to select the “Cross-Platform” section. From there, you want to select the “Forms Xaml Page” template. This will include all the necessary dependencies for your Xamarin Forms mobile app. Like I said, super simple, but when i chose the wrong one in the XAML section, I had no idea why I was getting so many errors.

2

 

Happy Hacking!

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *