im trying to navigate to parent fragment after completing the action in the child fragment. im able to successfully navigate from parent to child but having trouble when going backwards. the code im using currently is

From Parent to Child

 public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.action_new:
                    FragmentManager.BeginTransaction()
                                   .Replace(Resource.Id.content_frame, EditAccountFragment.NewInstance())
                                   .AddToBackStack("AccountFragment")
                                   .Commit();                   
                    break;
            }
            return base.OnOptionsItemSelected(item);
        }  

From Child to Parent

public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
                case Resource.Id.action_save:
                    SaveAccount();
                    GotoAccounts();
                    Toast.MakeText(Activity, "Save Account", ToastLength.Short).Show();
                    break;
                case Resource.Id.action_cancel:
                    GotoAccounts();
                    Toast.MakeText(Activity, "Save Account Cancelled", ToastLength.Short).Show();
                    break;
            }
            return base.OnOptionsItemSelected(item);
        }

        private void GotoAccounts()
        {

            AccountsFragment accountsFragment = new AccountsFragment();
            FragmentManager.BeginTransaction()
                                   .Replace(Resource.Id.content_frame, accountsFragment)
                                   .Commit();
        }

        private void SaveAccount()
        {
            Account.AccountName = Title.Text;
            Account.Note = Note.Text;
            _accountDM.SaveAccount(Account);
        }

Can anyone please help me in getting this work to navigate from Child to Parent? i want the user to redirect to listing page once he save the account in child fragment.

Thanks for all or Any help.

Related posts

Recent Viewed