tags:

views:

204

answers:

1

Hi!

I am working with a Silverlight application with some TimePicker controls and some TextBoxes. The XAML code like

  <toolkit:TimePicker x:Name="time" Width="100" HorizontalAlignment="Left" Value="{Binding FromDatetime, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True}"/>
  <Button HorizontalAlignment="Left" Content="Button" Height="23" x:Name="button1" Width="75" Click="button1_Click" />
  <TextBox Height="24" Name="text" Width="120" HorizontalAlignment="Left" Text="{Binding Path=FromDatetime, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnExceptions=True, ValidatesOnDataErrors=True}"/>
  <sdk:ValidationSummary Name="errorSummary" />

My problem is, when i enter some invalid value and press the button (these is only a SubmitChanges() to a DataContext in my button1_Click handler), the TimePicker control don't show me any error message. In my case, I've tried 3 patterns.

  1. TimePicker control and Button
  2. TimePicker control, ValidationSummary, and Button
  3. TextBox and Button
  4. TextBox, ValidationSummary, and Button

The results are,
pattern 1: shows no error message and no red thin border around the TimePicker
pattern 2: the TimePicker is just the same as pattern 1, but ValidationSummary shows the error message
pattern 3: the TextBox shows error message and an red thin border
pattern 4: both the TextBox and the ValidationSummary show error message

So, how I can let the TimePicker show me the error message just like the TextBox?

Thanks.

A: 

If you are using Silverlight 3 then this link describes that the default datepicker supports the validation error, that is why it shows up in the ValidationSummary but the default template of the datepicker does not have a default state to display these errors.

There are also some links available where you can get customized date picker templates, or you can create your own templates.

Johannes