protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SupportActionBar.Hide();
            SetContentView(Resource.Layout.Login);
            loginViewModel = new LoginViewModel();
            ServiceLocator.Dispatcher = new DispatchAdapter(this);
            loginField = FindViewById<EditText>(Resource.Id.username);
            passwordField = FindViewById<EditText>(Resource.Id.password);
            submit = FindViewById<Button>(Resource.Id.submit);
            submit.SetOnClickListener(this);

            ServiceLocator.Messenger.Subscribe<BaseViewMessage>(m => 
            {
                switch (m.Content.message) 
                {
                    case BaseViewMessage.MessageTypes.CONNECTION_ERROR:
                        Toast.MakeText(this, "Erro de conexão", ToastLength.Short).Show();
                        break;
                    case BaseViewMessage.MessageTypes.LOGIN_CONNECTION_OK:
                        getCourses();
                        break;
                    case BaseViewMessage.MessageTypes.COURSE_CONNECTION_OK:
                        intent = new Intent(this, typeof(CoursesActivity));
                        intent.SetFlags(ActivityFlags.ClearTop);
                        StartActivity(intent);
                        break;
                    default:
                        break;
                }            
            });
        }
 private void MainPage_Loaded(object sender, RoutedEventArgs e)
 {
     ServiceLocator.Dispatcher = new DispatchAdapter();
     loginViewModel = new LoginViewModel();
     progressBar = new PerformanceProgressBar();
     progressBar.IsIndeterminate = true;
     ServiceLocator.Messenger.Subscribe<BaseViewMessage>(m =>
     {
         switch (m.Content.message)
         {
             case BaseViewMessage.MessageTypes.CONNECTION_ERROR:
                 ServiceLocator.Dispatcher.invoke(() => 
                 {
                     ToastPrompt toast = new ToastPrompt();
                     toast.Message = "Erro de conexão";
                     toast.Show();
                     if (ContentPanel.Children.Contains(progressBar))
                         this.ContentPanel.Children.Remove(progressBar);
                 });
                 break;
             case BaseViewMessage.MessageTypes.LOGIN_CONNECTION_OK:
                 getCourses();
                 break;
             case BaseViewMessage.MessageTypes.COURSE_CONNECTION_OK:
                 ServiceLocator.Dispatcher.invoke(() =>
                 {
                     NavigationService.Navigate(new Uri("/Views/CoursePage.xaml", UriKind.Relative));
                 });
                 break;
             default:
                 break;
         }
     });
 }
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.NavigationController.NavigationBar.Hidden = true;
			loginViewModel = new LoginViewModel();

			this.submit.TouchUpInside += (sender, e) => 
			{
				dialog = new UILoadingView("Carregando","Por favor aguarde");
				dialog.Show();
				loginViewModel.submitLoginData(login.Text,password.Text);
			};

			ServiceLocator.Messenger.Subscribe<BaseViewMessage>(m => 
			{
				switch (m.Content.message) 
				{
				case BaseViewMessage.MessageTypes.CONNECTION_ERROR:
					ServiceLocator.Dispatcher.invoke(() =>
					{
						if (dialog != null) 
						{
							dialog.DismissWithClickedButtonIndex(0,true);
						}
						new UIAlertView("Erro","Nao foi possivel se conectar com o servidor",null,"Fechar",null).Show();
					});
					break;
				case BaseViewMessage.MessageTypes.LOGIN_CONNECTION_OK:
					getCourses();
					break;
				case BaseViewMessage.MessageTypes.COURSE_CONNECTION_OK:
					ServiceLocator.Dispatcher.invoke(() =>
					{
						coursesPage = new CoursesViewController();
						this.NavigationController.PushViewController(this.coursesPage,true);
					});
					break;
				default:
					break;
				}            
			});
		}