How to Navigate Through a Xamarin.Forms App

Navigation in the MVVM architectural pattern seems a pretty tough task and most commonly found solutions don’t really satisfy me.
They are overly complex, involve lots of code or don’t seem elegant at all. Some solutions just statically specify the target page as a string (in Windows/Windows Phone/UWP apps):


In Xamarin.Forms, navigation requires you to specify an instance of Page to navigate to. Usually, you would write code like this:

this.Navigation.Navigate(new SubPage());

This is bad for a couple of reasons:

  1. Navigation is a property of the Page type – you’ll have to somehow pass this to your ViewModel or have some kind of glue in your code behind.
  2. Since we’re calling the constructor of SubPage here, we’re coupling these classes tightly. This means we cannot comfortable test the navigation portion in our ViewModel.
  3. Navigation without Pages is not possible – that means that unit tests would rely on the Xamarin.Forms framework, which they should not need to.

In this article, I will present a pattern that – at least in my eyes – solves these problems while still allowing easy configurability and short, elegant code. Let’s get started.

Continue reading “How to Navigate Through a Xamarin.Forms App”

How to Create Your First .NET Application, on Linux, in 5 Minutes or less

Let’s say you wanted to become a developer for Microsoft .NET languages, such as C#. You’d have very good reasons to do so – C# is a powerful language (one might be tempted to say it’s Java done right), and .NET is a really great ecosystem.
Unfortunately, your clients demand your programs run on Linux systems – or you have chosen Linux as your primary development environment, so just installing Visual Studio is not an option for you. And since .NET applications only run on Windows, you’d be out of business within a couple of days, right?

This is where .NET Core comes into play: .NET Core is a cross-platform platform for .NET applications (try saying that three times in a row!). It’s easily installed on Unix (as well as Mac OS or Windows). For Ubuntu 16.4, run the following commands. For other platforms, check out the official download page.

Continue reading “How to Create Your First .NET Application, on Linux, in 5 Minutes or less”