views:

417

answers:

1

I m using a Dataform that is binded to a entity on my view model, for one field i need to create a combobox of items , i create it and bind it ok using this code on the autogenerating event:

            ComboBox makes = new ComboBox();
              Binding selectedItem = new Binding("conc_claimtype")
            {  
                ValidatesOnExceptions = true,
                ValidatesOnDataErrors = true,
                 ValidatesOnNotifyDataErrors = true,
                NotifyOnValidationError= true,
                Mode = BindingMode.TwoWay
            };
            makes.Items.Add("AI");
            makes.Items.Add("CO");
            makes.Items.Add("RE");

            makes.SetBinding(ComboBox.SelectedItemProperty, selectedItem);
            DataField makesField = new DataField {  Content = makes, Label = e.Field.Label };
            e.Field = makesField;
            e.Cancel = false;

I m trying to figure how i can make the popup appear in the combobox when the field is required and show the error message as the regular textbox does, if u set it to required and didn't select, it gives the validation error because i can see it on the ValidationSummary, but it dosen't schow the display label, only the error message, i think it maybe a bug with it.

what i really need it's to show that field is required with that popup like the textbox, i think i have to get some kind of style to the combobox to show validation erros right? where can i find this syle?

+2  A: 

I solved it making a small hack , i add a validation rule on the metadata of the domaincontext where i said the value coulnd't be a empty string, then i add a converter to the binding in the combobox, and when it is null i convertback to a emptystring and that way i got the validation working adn popup with the error message apear on the combobox.

I can post some code here if anyone needs to solve this issue.

My first question on stackoverflow, and i answer it myself ;) lol

Rui Marinho