예제 #1
0
        public override void ViewDidLoad()
        {
            AsyncInitialize();
            base.ViewDidLoad();

            TabBarController.NavigationItem.LeftBarButtonItems = new UIBarButtonItem[] { TabBarController.NavigationItem.RightBarButtonItems[0], new UIBarButtonItem(_addButton) };
            _addButton.TouchDown += delegate
            {
                ViewModel.AddCommand.Execute(null);
            };
            _addButton.TranslatesAutoresizingMaskIntoConstraints    = false;
            _addButton.WidthAnchor.ConstraintEqualTo(32.0f).Active  = true;
            _addButton.HeightAnchor.ConstraintEqualTo(32.0f).Active = true;
            _addButton.SetImage(new UIImage("add.png"), UIControlState.Normal);

            _source = new MySimpleTableViewSource(tasksTable, TasksTableViewCell.Key, TasksTableViewCell.Key);

            var set = this.CreateBindingSet <TasksTabView, TasksTabViewModel>();

            set.Bind(_source).To(vm => vm.Tasks);
            set.Apply();

            tasksTable.Source       = _source;
            tasksTable.ContentInset = UIEdgeInsets.FromString("20.0, 20.0, 20.0, 20.0");
            tasksTable.RowHeight    = 100;
            tasksTable.ReloadData();

            _source.SelectedItemChanged += (args, e) =>
            {
                var indexPath = tasksTable.IndexPathForSelectedRow;
                var index     = indexPath.Row;
                ActionSheetButtonsTouchUpInside(args, e, index);
                ViewModel.CurrentTask((CurrentTaskItem)_source.SelectedItem);
            };
        }