コード例 #1
0
        public bool OnNavigationItemSelected(int itemPosition, long itemId)
        {
            if (cirrentNavigation == itemPosition)
            {
                return(true);
            }

            activeFragment.As <CreateTransactionFragment>(f => f.TransactionCreated -= UpdatePendingTransactionCount);

            switch (itemPosition)
            {
            case 0:
            {
                var createTransactionFragment = new CreateTransactionFragment(repository);
                createTransactionFragment.TransactionCreated += UpdatePendingTransactionCount;
                activeFragment = createTransactionFragment;
                break;
            }

            case 1:
            {
                activeFragment = new TotalFragment(repository);
                break;
            }

            default: throw new ArgumentOutOfRangeException();
            }

            FindViewById <ViewGroup>(Resource.Id.Content).RemoveAllViews();
            using (var t = FragmentManager.BeginTransaction())
            {
                t.Add(Resource.Id.Content, activeFragment);
                t.Commit();
            }
            cirrentNavigation = itemPosition;
            return(true);
        }