Xamarin.Forms ViewModel Binding

In Xamarin.Forms ViewModel binding is done as we do in WPF. BindingContext of a view can be set in XAML or in code behind. Lets have a look at both:

In XAML, ViewModel is set in ContentPage.BindingContent :

For setting BindingContext from LoginPage.xaml.cs code file:

The xaml way is helpful in getting intellisense help while Binding Commands and Properties.

The Code behind way is helpful if you need to pass any parameter in the constructor.