public CustomContentView(bool navigationBar, object bindingContextData)
 {
     MvvmMessagingCenter.Init(this);
     ViewModel           = bindingContextData ?? Activator.CreateInstance(typeof(BaseViewModel));
     this.BindingContext = ViewModel;
     NavigationPage.SetHasNavigationBar(this, navigationBar);
 }
 private void BtnThrowException_Clicked(object sender, EventArgs e)
 {
     try
     {
         throw new Exception("custom exception is thrown!!!");
     }
     catch (Exception exception)
     {
         MvvmMessagingCenter.SendException(this, exception); //subcriber is auto change to currentPage
     }
 }
        public MainPage() : base(false, new MainPageViewModel()) //disabled navigationbar and sets viewModel
        {
            InitializeComponent();
            //
            SetCommand("CustomCmd", CustomCmdMth);        //setter

            CallCommand("CustomCmd", false);              //you can access xaml properties while call from in ctor
            //
            SetCommand("BtnCallCommand", BtnCallFromCmd); //setter
            MvvmMessagingCenter.SubcribeIncomingEvent(this, "testMessage");
        }
 private async void BtnDyncmc_Clicked(object sender, EventArgs e)
 {
     try
     {
         throw new Exception("redirected custom exception to another page!!!");
     }
     catch (Exception exception)
     {
         MvvmMessagingCenter.SendException(this, exception); //subcriber is auto change to currentPage
         await Navigation.PushAsync(new ExceptionPage());
     }
 }
 private void BtnMessaningCenter1_Clicked(object sender, EventArgs e)
 {
     MvvmMessagingCenter.SendIncomingEvent(this, "testMessage", new { userName = "******" });
 }
Example #6
0
 protected override void OnAppearing()
 {
     MvvmMessagingCenter.Init(this);
     base.OnAppearing();
 }