예제 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="newItemFactory">Creates a new item for the list.</param>
        /// <param name="items">Optionally pass in an initial list of items</param>
        /// <param name="addedAction">Action to perform when an item is added.</param>
        /// <param name="deleted">Action to perform when an item is deleted.</param>
        /// <param name="canDelete">Determines if an item can be deleted. This is called once before the deletion operation is performed.</param>
        public OrderedListViewModel(
            Func <TItemType> newItemFactory,
            IEnumerable <TItemType> items    = null,
            Action <TItemType> addedAction   = null,
            Func <TItemType, bool> deleted   = null,
            Func <TItemType, bool> canDelete = null)
        {
            if (newItemFactory == null)
            {
                throw new ArgumentNullException(nameof(newItemFactory));
            }

            if (items != null)
            {
                foreach (var item in items)
                {
                    Add(item);
                }
            }

            _newItemFactory = newItemFactory;
            _addedAction    = addedAction;
            _deleted        = deleted;
            _canDelete      = canDelete;

            MoveUpCommand       = new SimpleRelayCommand(MoveUp, CanMoveUp);
            MoveDownCommand     = new SimpleRelayCommand(MoveDown, CanMoveDown);
            DeleteCommand       = new SimpleRelayCommand(Delete, CanDelete);
            MoveToTopCommand    = new SimpleRelayCommand(MoveToTop, CanMoveToTop);
            MoveToBottomCommand = new SimpleRelayCommand(MoveToBottom, CanMoveToBottom);
            InsertAboveCommand  = new SimpleRelayCommand(InsertAbove, CanInsertAbove);
            InsertBelowCommand  = new SimpleRelayCommand(InsertBelow, CanInsertBelow);
        }
예제 #2
0
        public MainViewModel(ITextEditService textEditService)
        {
            if (textEditService == null) throw new ArgumentNullException(nameof(textEditService));

            _textEditService = textEditService;

            EditTextCommand = new SimpleRelayCommand(EditText);
        }
예제 #3
0
        public MainViewModel(IFileDialogService fileDialogService)
        {
            if (fileDialogService == null) throw new ArgumentNullException(nameof(fileDialogService));
            _fileDialogService = fileDialogService;

            OpenFileCommand = new SimpleRelayCommand(OpenFile);
            SaveFileCommand = new SimpleRelayCommand(SaveFile);
        }
예제 #4
0
        public MainViewModel(IMessageBoxService messageBoxService)
        {
            if (messageBoxService == null) throw new ArgumentNullException(nameof(messageBoxService));

            _messageBoxService = messageBoxService;

            ShowMessageBoxCommand = new SimpleRelayCommand(ShowMessageBox);
            AskYesNoCommand = new SimpleRelayCommand(AskYesNo);
        }
예제 #5
0
        public MainViewModel(IViewService viewService)
        {
            if (viewService == null) throw new ArgumentNullException(nameof(viewService));

            _viewService = viewService;

            EditTextCommand = new SimpleRelayCommand(EditText);
            DisplayTextCommand = new SimpleRelayCommand(DisplayText);
        }
예제 #6
0
 public MainViewModel()
 {
     SelectFirstName = new SimpleRelayCommand(() =>
     {
         IsLastNameFocused = false;
         IsFirstNameFocused = true;
     });
     SelectLastName = new SimpleRelayCommand(() =>
     {
         IsFirstNameFocused = false;
         IsLastNameFocused = true;
     });
 }
 public EditTextViewModel()
 {
     OkCommand = new SimpleRelayCommand(Ok);
 }
예제 #8
0
 public MainViewModel()
 {
     OkCommand = new SimpleRelayCommand(Ok);
     CancelCommand = new SimpleRelayCommand(Cancel);
 }