Click here to Skip to main content
12,635,398 members (25,723 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# WPF C#4.0
hai to all ,
i have to put validation on EstimationStartDate and EstimatedCompletionFields...

I Tried like this.

       private DateTime _estimatedStartDate;
       [DataMember]
       public DateTime EstimatedStartDate
       {
           get { return _estimatedStartDate; }
           set
           {
               if (value == _estimatedStartDate)
                   return;

               _estimatedStartDate = value;
               NotifyPropertyChange(EstimatedStartDate);
           }

       }

       private DateTime _estimatedCompletionDate;
       [PropertyComparisonValidator(EstimatedStartDate", ComparisonOperator.GreaterThanEqual , MessageTemplate = Estimated Completion Date should be Greater than or equal to the Estimated Start Date)]
       [DataMember]
       public DateTime EstimatedCompletionDate
       {
           get{ return _estimatedCompletionDate; }
           set
           {
               if (value == _estimatedCompletionDate)
                   return;

               _estimatedCompletionDate = value;
               NotifyPropertyChange("EstimatedCompletionDate");
           }

       }


This is working fine when i changed the dates ...

Those are the ComboBox Fields...

when i changed the ExstimationCompletionDate combobox field ...I am getting default time as 12:00:00 A.M for the fields ...so I was not able to save...
I try to changed EstimatedComplitionData combobox then I get that time...

please help me ...
Posted 28-Oct-10 2:27am
Updated 28-Oct-10 2:28am
JF201555K
v2

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Unless you actually have an estimated start/end time, you should both change your properties to the following:


public DateTime WhicheverDate
{
    get{ return _backingField.Date; }
    set
    {
        if (value.Date == _backingField.date)
            return;
        _backingField. = value.Date;
        NotifyPropertyChange("WhicheverDate");
    }
}


This removes the ambiguity around the time. If you need to keep the time, obviouly this is not a solution.
  Permalink  
Comments
satyagrahi_2010 29-Oct-10 0:51am
   
Nice Answer Help me...
Thanks Barrow...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161208.2 | Last Updated 28 Oct 2010
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100