Ejemplo n.º 1
0
        public EditableSet(IBindableCollection <TElement> originals, Action <TElement> editItemAction, Action <TElement> addItemAction, Action <TElement> deleteItemAction)
        {
            _originals        = originals;
            _deleteItemAction = deleteItemAction;
            _addItemAction    = addItemAction;
            _editItemAction   = editItemAction;

            _inserted          = new ObservableCollection <Editable <TElement> >();
            _editableOriginals = _originals.AsBindable().Select(orig => new Editable <TElement>(orig));
            _editableOriginals.Evaluate();

            _undoItemChangesCommand = new DelegateCommand <Editable <TElement> >(
                item => UndoItemChanges(item),
                item => item.HasChanges
                );
            _deleteItemCommand = new DelegateCommand <Editable <TElement> >(
                item => DeleteItem(item),
                item => true
                );
            _undoChangesCommand = new DelegateCommand(
                ignored => UndoChanges(),
                ignored => true
                );
            _commitChangesCommand = new DelegateCommand(
                ignored => CommitChanges(),
                ignored => true
                );
        }