Exemplo n.º 1
0
        private void DisplayInlineErrors(ref IEnumerable <ViewModelError> viewModelErrors)
        {
            var page = _navigationService.CurrentPage;

            var popupErrorItems = viewModelErrors.ToList();

            // check if PropertyNameValidator exist on the current page

            foreach (var error in viewModelErrors)
            {
                if (error?.Errors == null)
                {
                    continue;
                }

                foreach (var e in error.Errors)
                {
                    // Looking for UI element called {PropertyNameValidator}
                    var validator = page?.FindByName($"{e.Key}Validator");

                    if (validator == null)
                    {
                        continue;
                    }

                    validator.SetProperty("Text", e.Value.FirstOrDefault());
                    ActiveInlineValidators.AddReplace(e.Key, page.GetType().Name);
                    popupErrorItems?.Remove(error);
                }
            }

            viewModelErrors = popupErrorItems.AsEnumerable();
        }
Exemplo n.º 2
0
        public void ClearInlineValidators()
        {
            var page = _navigationService.CurrentPage;

            foreach (var validatorKey in ActiveInlineValidators)
            {
                if (validatorKey.Value != page.GetType().Name)
                {
                    return;
                }

                // Looking for UI element called {PropertyNameValidator}
                var validator = page?.FindByName($"{validatorKey.Key}Validator");

                validator?.SetProperty("Text", "");
            }

            ActiveInlineValidators.Clear();
        }