DatePicker - Validation Rules

May 22, 2009 at 7:48 PM

Hi,

Do you know of any good way to bind a datepicker with validation rules?

What I wanted to do is something like this:

        <toolkit:DatePicker Name="dpActualStartDate" Grid.Column="1" Grid.Row="4"
                            HorizontalContentAlignment="Stretch" VerticalContentAlignment="Center"
                            HorizontalAlignment="Left" VerticalAlignment="Center"
                            Height="25" Width="250">
            <toolkit:DatePicker.SelectedDate>
                <Binding Path="ActualStartDate"
                             UpdateSourceTrigger="PropertyChanged"
                             ValidatesOnExceptions="true"
                             NotifyOnValidationError="True" >
                       <Binding.ValidationRules>
                              <buisness:DateValidation />
                       </Binding.ValidationRules>
                </Binding>
            </toolkit:DatePicker.SelectedDate>
        </toolkit:DatePicker>

The xaml code above will not build because ValidationRules is NOT a binding member. Is there any alternative solution to get validation bound to a DatePicker?

Many thanks...

Coordinator
May 22, 2009 at 8:18 PM

Binding does have a property called ValidationRules:

http://msdn.microsoft.com/en-us/library/system.windows.data.binding.validationrules.aspx

What is the exact error you get?  Does your buisness:DataValidation derive from ValidationRule?

-Brandon

May 22, 2009 at 8:31 PM

ValidationRules doesnt seem to be a property of Binding if the Binding is implemented using the DatePicker control... If this was a TextBlock control, then Binding with Validation Rules is fine.

Aug 24, 2009 at 5:10 PM

Do we have an answer for this?

-Ranjith