This is a migrated thread and some comments may be shown as answers.

How use the validation binding in the Value option and set a text value

1 Answer 209 Views
MaskedInput (Numeric, DateTime, Text, Currency)
This is a migrated thread and some comments may be shown as answers.
Alexandre
Top achievements
Rank 1
Alexandre asked on 06 Jun 2018, 12:45 PM

Hi, I am creating a project using the valiadtion as IDataErrorInfo, but I need to create a simple edit form that the RadMaskedTextInput components have the Value option filled with a value.

 

This is my example TextInput:

                <telerik:RadMaskedTextInput Value="{Binding Interessado, Mode=TwoWay, ValidatesOnDataErrors=True, NotifyOnValidationError=True, ValidatesOnExceptions=True}"
                                            x:Name="Interessado" 
                                            EmptyContent="Nome ou razão social"
                                            Culture="pt-BR"
                                            Mask=""
                                            InputBehavior="Insert"
                                            UpdateValueEvent="PropertyChanged" 
                                            HorizontalAlignment="Stretch"/>

 

And this is my validation class:

    public class Validations : IDataErrorInfo
    {
        public string Interessado { get; set; }

        #region IDataErrorInfo

        public string this[string columnName]
        {
            get
            {
                if ("Interessado" == columnName)
                {
                    if (String.IsNullOrEmpty(Interessado))
                    {
                        return "Campo Nome do Interessado é obrigatório!";
                    }
                }
   
                return "";
            }
        }

        public string Error
        {
            get { throw new NotImplementedException(); }
        }
    }

 

So, how can I set the Value with a text (because I am using the Value option for Binding)?

1 Answer, 1 is accepted

Sort by
0
Dinko | Tech Support Engineer
Telerik team
answered on 11 Jun 2018, 11:00 AM
Hi Alexandre,

Thank you for the provided code snippets.

If I have understood your questions correctly you want to set a default value. Correct me if I am in the wrong direction. In this case, you can set the Interessado property in the constructor of the Validations class. I have created a sample project, based on the provided code snippets, which demonstrates this approach.

Give this project a try and let me know if it works for you. If not, can you elaborate more on your approach?

Regards,
Dinko
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
MaskedInput (Numeric, DateTime, Text, Currency)
Asked by
Alexandre
Top achievements
Rank 1
Answers by
Dinko | Tech Support Engineer
Telerik team
Share this question
or