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

ValidatesOnExceptions for RadComboBox Text property

2 Answers 108 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Andre
Top achievements
Rank 1
Andre asked on 20 Jan 2011, 11:20 PM
It appears that RadComboBox does not support ValidatesOnExceptions for the Text property.  Here is what I am trying to use in my XAML.

Text="{Binding InitialsText, Mode=TwoWay, ValidatesOnExceptions=true, NotifyOnValidationError=true}"

I need to use the Text property since the IsEditable property is true.  We need to allow users to enter a value or select from the list.

When a validation error is thrown it is not trapped and I get an unhandled System.ComponentModel.DataAnnotations.ValidationException (code is below)

/// <summary>
/// text for the selected initials - required since field is editable
/// </summary>
[Required()]    //TODO AEO CAUSES ERRORS
public string InitialsText
{
    get { return initialsText; }
    set
    {
        SetProperty("InitialsText", ref initialsText, ref value);
 
        ValidationContext context = new ValidationContext(this, null, null);
        context.MemberName = "InitialsText";
        System.ComponentModel.DataAnnotations.Validator.ValidateProperty(value, context);
    }
}

Does the RadComboBox Text property support validation exceptions?  The approach I am using works perfectly for the RadComboBox SelectedItem property.

Regards,
Andre

2 Answers, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 26 Jan 2011, 12:49 PM
Hello Andre,

Thank you for contacting us.

I have tried your approach and it seems to work properly. Could you please check out the sample project I am sending you.
If you still experience difficulties please send us your project, so that we can run it here locally in order to track down the source of the problem.

Kind regards,
Konstantina
the Telerik team
Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
0
Andre
Top achievements
Rank 1
answered on 27 Jan 2011, 08:32 PM
Konstantina,

Thank you for your follow up.  I was able to determine my issue and the Text property does work.  By using DataAnnotations on my ViewModel, specifically a string type property, the validation exception was not being trapped on the object instantiation.  It is trapped properly when the user control is in use since the UI takes care of the error handling.  I have modified my code to account for this.

Regards,
Andre
Tags
ComboBox
Asked by
Andre
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Andre
Top achievements
Rank 1
Share this question
or