views:

1256

answers:

1

I have a SL3 application in which I'm using DataForm for my data entry. I want my form to look in the way I like it, so, I use <dataControls:DataForm.EditTemplate> and inside the template I have my good looking form design.

the main issue is, inside the template I have to use normal controls (like TextBox) instead of the "field" controls (like DataFormTextField). they both work almost the same with the big difference when it gets to validation.

if I throw an exception in the setter of the property to which they are bound, they both show the proper red sign and error, but if I decorate the property by validation attributes (for example [Required(ErrorMessage = "can't be empty!")]), only the DataFormTextField control and not the TextBox control will show the error. in both cases my ErrorSummary control has the error in its collection, so I can see the error is being taken into account...

Any help is appreciated.

A: 

Are you using the template field?

   <df:DataFormTemplateField FieldLabelContent="Year"> 
      <df:DataFormTemplateField.DisplayTemplate> 
        <DataTemplate> 
          <TextBox Text="{Binding Year}" HorizontalAlignment="Left" /> 
        </DataTemplate> 
      </df:DataFormTemplateField.DisplayTemplate> 
      <df:DataFormTemplateField.EditTemplate> 
        <DataTemplate> 
          <TextBox Text="{Binding Year}" HorizontalAlignment="Left" /> 
        </DataTemplate> 
      </df:DataFormTemplateField.EditTemplate> 
    </df:DataFormTemplateField>
vidalsasoon
something very similar, yes.
Ali Shafai
I mean is your "Textbox" within a DataFormTemplateField?I was thinking that if your Textox is not in the template field, it would explain why the validation errors wouldnt show up.
vidalsasoon