public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Vm.Init();

            AddButton = new UIBarButtonItem(UIBarButtonSystemItem.Add);
            NavigationItem.SetRightBarButtonItem(AddButton, false);
            AddButton.Clicked += (sender, args) => { };

            // bindings
            AddButton.SetCommand("Clicked", Vm.AddPersonCommand);
            _currentIndexBinding = this.SetBinding(
                () => CurrentIndex,
                () => Vm.CurrentIndex);

            source = Vm.People.GetTableViewSource(
                CreateTaskCell,
                BindTaskCell,
                factory: () => new PeopleListObservableTableSource());

            PeopleTableView.Source    = source;
            PeopleTableView.Delegate  = this;
            PeopleTableView.RowHeight = 185;
            PeopleTableView.ReloadData();


            // Add Important Message View
            var importantMessage      = ImportantMessageView.Create();
            var importantMessageFrame = new CGRect(0, 0, View.Frame.Width, 50);

            importantMessage.Frame = importantMessageFrame;
            View.AddSubview(importantMessage);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            try
            {
                viewModel = SimpleIoc.Default.GetInstance <CountersViewModel>();

                var source = new CountersTableViewSource();
                TableView.Source = source;

                addCounterButton = new UIBarButtonItem(UIBarButtonSystemItem.Add);
                addCounterButton.AccessibilityIdentifier = "add_counter_button";
                NavigationItem.SetRightBarButtonItem(addCounterButton, false);

                bindings.Add(this.SetBinding(() => viewModel.Counters, () => DataSource));

                // Using this - new view controller is shown
                //addCounterButton.Clicked += (sender, e) =>
                //{
                //    var storyboard = UIStoryboard.FromName("Main", null);
                //    var vc = storyboard.InstantiateViewController("CounterView");
                //    ShowViewController(vc, this);
                //};

                // Using this - app crashes
                addCounterButton.SetCommand(nameof(UIBarButtonItem.Clicked), viewModel.ShowAddNewCounterCommand);
            }
            catch { }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            if (NavigationController?.InteractivePopGestureRecognizer != null)
            {
                NavigationController.InteractivePopGestureRecognizer.Enabled = false;
            }

            var loc = ServiceLocator.Current.GetInstance <ILocalizedStringProvider>();

            LogoutButton.Title = loc.GetLocalizedString(Localized.Logout_Label);
            LoginButton.Title  = loc.GetLocalizedString(Localized.Login_Label);

            if (!DelayedParameter)
            {
                (GetViewModel() as IAcceptParameterViewModel)?.SetParameter(NavigationParameter);
            }

            if (!DelayedActivation)
            {
                var toActivate = GetViewModel() as IActivationEnabledViewModel;
                toActivate?.ActivateAsync().ConfigureAwait(true);
            }

            LoginButton.Clicked += LoginButtonClick;
            LogoutButton.SetCommand("Clicked", GetViewModel().LogoutCommand);
        }
Beispiel #4
0
        public static UIBarButtonItem SetCommand(this UIBarButtonItem control, RelayCommand command)
        {
            control.Clicked += (s, e) => { };

            control.SetCommand(Events.Clicked, command);
            control.Enabled = command.CanExecute(null);

            return(control);
        }
        public override void ViewDidLoad()
        {
            View = new UniversalView();
            base.ViewDidLoad();
            InitializeComponent();

            Title = "Details";

            FlowerImage.SetImage(
                new NSUrl(Vm.ImageUri.AbsoluteUri),
                UIImage.FromBundle("flower_256_magenta.png"));

            this.SetBinding(
                () => Vm.Model.Name)
                .WhenSourceChanges(
                    () =>
                    {
                        // iOS is quite primitive and requires layout recalculation when the content
                        // of UI elements changes. This is a good place to do that.

                        NameText.Text = Vm.Model.Name;
                        NameText.SizeToFit();
                        NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height);
                    });

            this.SetBinding(
                () => Vm.Model.Description)
                .WhenSourceChanges(
                    () =>
                    {
                        DescriptionText.Text = Vm.Model.Description;
                        DescriptionText.SizeToFit();
                        DescriptionText.Frame = new CGRect(0, 0, 300, DescriptionText.Bounds.Height);

                        Scroll.ContentSize = new CGSize(300, DescriptionText.Bounds.Height);
                        Scroll.SetNeedsLayout();
                    });

            SeeCommentButton.Clicked += (s, e) =>
            {
                // iOS is the only framework where we decided to split the comments
                // on a different page. This is a good example that you can easily
                // have different UI experience even though the ViewModel and Model are the same

                var controller = Vm.Model.Comments.GetController(
                    CreateCommentCell,
                    BindCommentCell);
                controller.Title = "Comments";

                var addCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
                addCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);
                controller.NavigationItem.SetRightBarButtonItem(addCommentButton, false);

                AppDelegate.MainNavigationController.PushViewController(controller, true);
            };
        }
Beispiel #6
0
        public override void ViewDidLoad()
        {
            View = new UniversalView();
            base.ViewDidLoad();
            InitializeComponent();

            Title = "Details";

            FlowerImage.SetImage(
                new NSUrl(Vm.ImageUri.AbsoluteUri),
                UIImage.FromBundle("flower_256_magenta.png"));

            this.SetBinding(
                () => Vm.Model.Name)
            .WhenSourceChanges(
                () =>
            {
                // iOS is quite primitive and requires layout recalculation when the content
                // of UI elements changes. This is a good place to do that.

                NameText.Text = Vm.Model.Name;
                NameText.SizeToFit();
                NameText.Frame = new CGRect(140, 75, 170, NameText.Bounds.Height);
            });

            this.SetBinding(
                () => Vm.Model.Description)
            .WhenSourceChanges(
                () =>
            {
                DescriptionText.Text = Vm.Model.Description;
                DescriptionText.SizeToFit();
                DescriptionText.Frame = new CGRect(0, 0, 300, DescriptionText.Bounds.Height);

                Scroll.ContentSize = new CGSize(300, DescriptionText.Bounds.Height);
                Scroll.SetNeedsLayout();
            });

            SeeCommentButton.Clicked += (s, e) =>
            {
                // iOS is the only framework where we decided to split the comments
                // on a different page. This is a good example that you can easily
                // have different UI experience even though the ViewModel and Model are the same

                var controller = Vm.Model.Comments.GetController(
                    CreateCommentCell,
                    BindCommentCell);
                controller.Title = "Comments";

                var addCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
                addCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);
                controller.NavigationItem.SetRightBarButtonItem(addCommentButton, false);

                AppDelegate.MainNavigationController.PushViewController(controller, true);
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Add the add button to the navigation abr
            UIBarButtonItem btnAdd = new UIBarButtonItem();
            btnAdd.Title = "Add";
            btnAdd.SetCommand("Clicked", App.Bootstrapper.MainViewModel.NavigateToAddCommand);
            NavigationItem.RightBarButtonItem = btnAdd;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _source = Vm.Items.GetTableViewSource(
                BindTestTableViewCell,
                ReuseId,
                factory: () => new TableViewSourceEx());

            TableView.RegisterClassForCellReuse(typeof(TestTableViewCell), new NSString(ReuseId));

            _source.GetHeightForHeaderDelegate = () => 50;
            _source.GetViewForHeaderDelegate   = () =>
            {
                _headerView = new HeaderForTableView();

                _bindings.Add(
                    this.SetBinding(
                        () => _source.SelectedItem.Name,
                        () => _headerView.SelectedItemLabel.Text,
                        fallbackValue: "Nothing yet"));

                _bindings.Add(
                    this.SetBinding(
                        () => Vm.ToggledItems,
                        () => _headerView.ToggledItemsLabel.Text));

                return(_headerView);
            };

            TableView.Source = _source;

            var addButton = new UIBarButtonItem
            {
                Title = "Add"
            };

            addButton.SetCommand(Vm.AddCommand);

            var delButton = new UIBarButtonItem
            {
                Title = "Del"
            };

            var selectedItemBinding = this.SetBinding(() => _source.SelectedItem);

            _bindings.Add(selectedItemBinding);
            delButton.SetCommand(Vm.DeleteCommand, selectedItemBinding);

            NavigationItem.RightBarButtonItems = new[]
            {
                delButton,
                addButton,
            };
        }
Beispiel #9
0
        public override void ViewDidLoad()
        {
            Vm = (FlowerViewModel)Nav.GetAndRemoveParameter(this);

            SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null);
            NavigationItem.SetRightBarButtonItem(SaveCommentButton, false);

            _commentBinding = this.SetBinding(() => CommentText.Text);

            SaveCommentButton.SetCommand(
                Vm.SaveCommentCommand,
                _commentBinding);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            Vm = (FlowerViewModel)Nav.GetAndRemoveParameter(this);

            _tableController = Vm.Model.Comments.GetController(
                CreateCommentCell,
                BindCommentCell);

            _tableController.TableView = CommentsTableView;

            AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
            NavigationItem.SetRightBarButtonItem(AddCommentButton, false);
            AddCommentButton.SetCommand(Vm.AddCommentCommand);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            AddTaskButton = new UIBarButtonItem(UIBarButtonSystemItem.Add);
            this.NavigationItem.SetLeftBarButtonItem(AddTaskButton, false);

            //note this was needed when deploying to a real iPhone but worked
            //on the simulator without it. The Argument Exception Event not found clicked was thrown
            AddTaskButton.Clicked += (sender, e) => {};

            AddTaskButton.SetCommand("Clicked", Vm.AddTaskCommand);

            tableViewController           = Vm.TodoTasks.GetTaskListController(CreateTaskCell, BindTaskCell);
            tableViewController.TableView = TasksTableView;
        }
Beispiel #12
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            CollectionView.RegisterClassForSupplementaryView(
                // Needed if you want to provide a header or footer
                typeof(HeaderForCollectionView),
                UICollectionElementKindSection.Header,
                HeaderId);

            CollectionView.BackgroundColor = UIColor.White;

            _source = Vm.Items.GetCollectionViewSource <Item, TestCollectionViewCell>(
                BindCell,
                GetViewForSupplementaryElement,
                // Optional, for header and footer
                CellId,
                // Reuse Cell ID
                () => new CollectionViewSourceEx());
            // Last argument is optional, provides a way to define your own derived class and extend it.

            CollectionView.Source = _source;

            var addButton = new UIBarButtonItem
            {
                Title = "Add"
            };

            addButton.SetCommand(Vm.AddCommand);

            var delButton = new UIBarButtonItem
            {
                Title = "Del"
            };

            var selectedItemBinding = this.SetBinding(() => _source.SelectedItem);

            _bindings.Add(selectedItemBinding);
            delButton.SetCommand(Vm.DeleteCommand, selectedItemBinding);

            NavigationItem.RightBarButtonItems = new[]
            {
                delButton,
                addButton,
            };
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            // Set bindings
            NameBinding = this.SetBinding (() => tfTitle.Text)
                .UpdateSourceTrigger ("EditingDidEnd")
                .WhenSourceChanges (() => MainViewModel.Draft.Title = tfTitle.Text);

            ContentBinding = this.SetBinding (() => tfContent.Text)
                .UpdateSourceTrigger ("EditingDidEnd")
                .WhenSourceChanges (() => MainViewModel.Draft.Content = tfContent.Text);

            // Add the add button to the navigation abr
            UIBarButtonItem btnAdd = new UIBarButtonItem();
            btnAdd.Title = "Add";
            btnAdd.SetCommand("Clicked", MainViewModel.AddNoteCommand);

            NavigationItem.RightBarButtonItem = btnAdd;
        }
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            _tableController = Vm.Model.Comments.GetController(
                CreateCommentCell,
                BindCommentCell);

            _tableController.TableView = CommentsTableView;

            AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
            NavigationItem.SetRightBarButtonItem(AddCommentButton, false);
            AddCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            _tableController = Vm.Model.Comments.GetController(
                CreateCommentCell,
                BindCommentCell);

            _tableController.TableView = CommentsTableView;

            AddCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, null);
            NavigationItem.SetRightBarButtonItem(AddCommentButton, false);
            AddCommentButton.SetCommand("Clicked", Vm.AddCommentCommand);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            Vm.Initialize();

            AddTaskButton = new UIBarButtonItem(UIBarButtonSystemItem.Add);
            this.NavigationItem.SetLeftBarButtonItem(AddTaskButton, false);

            //note this was needed when deploying to a real iPhone but worked
            //on the simulator without it. The Argument Exception Event not found clicked was thrown
            AddTaskButton.Clicked += (sender, e) => { };

            AddTaskButton.SetCommand("Clicked", Vm.AddTaskCommand);

            source = Vm.TodoTasks.GetTableViewSource(
                CreateTaskCell,
                BindTaskCell,
                factory: () => new TaskListObservableTableSource());

            TasksTableView.Source = source;
        }
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null);
            NavigationItem.SetRightBarButtonItem(SaveCommentButton, false);

            _commentBinding = this.SetBinding(
                () => CommentText.Text)
                              .UpdateSourceTrigger("Changed");

            SaveCommentButton.SetCommand(
                "Clicked",
                Vm.SaveCommentCommand,
                _commentBinding);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            if (NavigationParameter == null)
            {
                throw new InvalidOperationException("No parameter found after navigation");
            }

            Vm = (FlowerViewModel)NavigationParameter;

            SaveCommentButton = new UIBarButtonItem(UIBarButtonSystemItem.Save, null);
            NavigationItem.SetRightBarButtonItem(SaveCommentButton, false);

            _commentBinding = this.SetBinding(
                () => CommentText.Text)
                .UpdateSourceTrigger("Changed");

            SaveCommentButton.SetCommand(
                "Clicked",
                Vm.SaveCommentCommand,
                _commentBinding);

            base.ViewDidLoad();
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var nav           = (NavigationService)ServiceLocator.Current.GetInstance <INavigationService>();
            var useCreateCell = (bool?)nav.GetAndRemoveParameter(this);

            if (useCreateCell == null || useCreateCell.Value)
            {
                _source = Vm.Items.GetTableViewSource(
                    CreateCell,
                    BindUiTableViewCell,
                    factory: () => new TableViewSourceEx());
            }
            else
            {
                _source = Vm.Items.GetTableViewSource(
                    BindTestTableViewCell,
                    ReuseId,
                    factory: () => new TableViewSourceEx());

                TableView.RegisterClassForCellReuse(typeof(TestTableViewCell), new NSString(ReuseId));
            }

            _source.GetHeightForHeaderDelegate = () => 50;
            _source.GetViewForHeaderDelegate   = () =>
            {
                _headerView = new HeaderForTableView();

                _bindings.Add(
                    this.SetBinding(
                        () => _source.SelectedItem.Title,
                        () => _headerView.SelectedItemLabel.Text,
                        fallbackValue: "Nothing yet"));

                return(_headerView);
            };

            TableView.Source = _source;

            var addButton = new UIBarButtonItem
            {
                Title = "Add"
            };

            addButton.SetCommand(Vm.AddCommand);

            var delButton = new UIBarButtonItem
            {
                Title = "Del"
            };

            var selectedItemBinding = this.SetBinding(() => _source.SelectedItem);

            _bindings.Add(selectedItemBinding);
            delButton.SetCommand(Vm.DeleteCommand, selectedItemBinding);

            NavigationItem.RightBarButtonItems = new[]
            {
                delButton,
                addButton,
            };
        }