public IToolbarItemViewModel Add(IToolbarItemViewModel item)
 {
     if (item == null)
     {
         throw new ArgumentNullException(nameof(item));
     }
     ToolbarItems.Add(item);
     return(item);
 }
        public EditableTableViewModel(IAlertController alerts, INavigationService navigationService, ISchedulerService schedulerService)
            : base(navigationService, schedulerService)
        {
            Intent  = TableIntent.Form; // More common?
            _alerts = alerts;
            _toggleEditModeCommand = new Command((obj) => ToggleEditMode());
            _editBarItem           = new TextToolbarItemViewModel("Edit", _toggleEditModeCommand);

            _editMode.ObserveOn(schedulerService.UiScheduler).Subscribe((em) =>
            {
                _editBarItem.Text = em ? DoneButtonCaption : EditButtonCaption;
                Sections.ForEach(s => s.EditMode = em);
            });

            Toolbar.Add(_editBarItem);
        }
Exemple #3
0
        public ToolbarItem CreateToolbarItem(IToolbarItemViewModel tb)
        {
            if (tb == null)
            {
                throw new ArgumentNullException(nameof(tb));
            }
            var item = new ToolbarItem()
            {
                Command          = tb.Command,
                CommandParameter = tb.CommandParameter,
                Icon             = tb.Icon,
                Text             = tb.Text,
                Priority         = tb.Position == ToolbarItemOrder.Secondary ? 0 : 1, // Renderer for iOS will switch secondaries to the right hand side.
            };

            item.BindingContext = tb;
            item.SetBinding(MenuItem.TextProperty, "Text");
            return(item);
        }