コード例 #1
0
        private void InitializeRecipient(Recipient recipient)
        {
            Recipient = new RecipientWrapper(recipient);
            Recipient.PropertyChanged += (sender, args) =>
            {
                if (!HasChanges)
                {
                    HasChanges = _recipientRepository.HasChanges();
                }

                if (args.PropertyName == nameof(Recipient.HasErrors))
                {
                    ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();
                }

                if (args.PropertyName == nameof(Recipient.Name))
                {
                    SetTitle();
                }
            };
            ((DelegateCommand)SaveCommand).RaiseCanExecuteChanged();

            if (Recipient.ID == 0)   //ID will be for a new recipient
            {
                Recipient.Name = ""; //trick to trigger validation for a new recipeint
            }

            SetTitle();
        }