Пример #1
0
        public UserViewModel(UserModel model, AbstractValidator<IUserModel> validator)
        {
            if (model == null) throw new ArgumentNullException("model");
            if (validator == null) throw new ArgumentNullException("validator");

            _validator = validator;
            _data = model;
            _backup = model.Clone() as UserModel;

            OkCommand = new RelayCommand(OkCommandExecute);
            CancelCommand = new RelayCommand(CancelCommandExecute);
        }
        public UserListViewModel(ChildWindow window, IList<UserModel> models, UserModelValidator validator)
        {
            _window = window;

            Data = new ObservableCollection<UserViewModel>();

            foreach (var model in models)
                Data.Add(new UserViewModel(model, validator));

            AddCommand = new RelayCommand(AddCommandExecute);
            DeleteCommand = new RelayCommand(DeleteCommandExecute);

            Messenger.Default.Register<UserViewResponseMessage>(this, UserViewResponseMessageReceived);
        }