Overview
My latest post about Xamarin Visual Studio Templates beat the record of visits. That’s why, I have decided to explore Xamarin development. I have chosen to go with Xamarin Forms and Visual Studio.
The most important part is that this is FOR FREE!!!
If you haven’t been here before, I’m working on most ridiculous technology stack by using Microservices with ASP.NET Core on Ubuntu. In the meantime I have set up a basic front-end build pipeline with gulp and tried Docker with CoreClr on Ubuntu.
Xamarin Forms
Xamarin Forms evolved and are trying to share as much code as possible. Until now Xamarin was offering writing one C# Cross Mobile backend code and adding native applications with C# code. Forms are offering an option to share UI code but using native controls.
From my perspective it’s much better. I’d rather write native application in Android/iOS then use C# for something that it wasn’t designed.
But sharing almost all code in my app… that’s a thing…
Code
You can find the code of this app on my GitHub Xamarin branch, but if it’s not there take a look on master.
Xamarin Forms and Visual Studio
Installation
That’s boring and takes a long time, but pretty straightforward if you have a good link: Setup And Install.
Project Template
I have decided to go with Portable Forms. If you are not aware about the difference between Portable and Shared, take a look on this post. This means that you should choose Cross Platform -> Blank App (Xamarin.Forms Shared).
In a result you will have:
- one shared project for all platforms
- one project per each platform with device specific files
Shared Code
As you can see, the key text is defined in Shared Library.
public class App : Application { public App () { // The root page of your application MainPage = new ContentPage { Content = new StackLayout { VerticalOptions = LayoutOptions.Center, Children = { new Label { XAlign = TextAlignment.Center, Text = "Welcome to Xamarin Forms!" } } } }; } }
Summary of Xamarin and Visual Studio
Running this code is possible from Visual Studio directly. Unfortunately Apple is Apple and due to license restrictions, you are not able to run iPhone app without a Mac. However this may change according to latest announcements from Microsoft.
Pingback: dotnetomaniak.pl
Pingback: Xamarin Forms And Visual Studio Templates Explained - How to Code .NET