Welcome to the Xceed Community | Help
Community Search  

Setting Min Date and Max Date for DatePicker Control

Sort Posts: Previous Next
  •  11-26-2008, 8:15 AM Post no. 17196

    Setting Min Date and Max Date for DatePicker Control

    Hello All,

     

    Need help on setting Minimum Date and Maximum Date in Xceed DatePicker Control. Searched alot but could not find any pointers for the same.

     Please help !!!!!

     

    Thanks and Regards

    SSA.

    Filed under:
  •  11-27-2008, 2:49 PM Post no. 17241 in reply to 17196

    Re: Setting Min Date and Max Date for DatePicker Control

    This is not possible, since there are no Min/MaxDate properties in the DatePicker at the moment.
    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  11-28-2008, 4:22 AM Post no. 17250 in reply to 17241

    Re: Setting Min Date and Max Date for DatePicker Control

    Hey,

    Thanks for the prompt reply. Can we have a workaround to restrict the range the DatePicker can use ?

    Please help !!!!

     

    Thanks and Regards

    SSA.

  •  12-02-2008, 3:19 PM Post no. 17306 in reply to 17250

    Re: Setting Min Date and Max Date for DatePicker Control

    Well, you could always create a CellEditor with a DatePicker as DataTemplate, and set the name of the DatePicker to PART_CellEditorBoundControl.

    Then you could bind the AttachedProperty xcdg:CellEditor.HasError on the DatePicker.SelectedDate to a Converter (you will need to create an IValueConverter) which evaluates if the selected date is within the range or not

    Then you could subscribe to the ValidationErrorChanging RoutedEvent, check the ParentColumn, and in the case that it is the min/max DatePicker column, set the event args error message to something meaningful, if it is out of range.


    e.g. :

         <local:MinMaxConverter x:Key="minMaxConverter" />

          <xcdg:CellEditor x:Key="minMaxDatePickerEditor"
                           >
            
             <xcdg:CellEditor.EditTemplate>
                <DataTemplate>
                   <xcdg:DatePicker Name="PART_CellEditorBoundControl"
                                       xcdg:CellEditor.HasError="{Binding RelativeSource={RelativeSource Self}, Path=SelectedDate, Converter={StaticResource minMaxConverter} }"
                                       xcdg:DataCell.IsCellFocusScope="True"
                                       SelectedDate="{xcdg:CellEditorBinding}"
                                    />
                </DataTemplate>
             </xcdg:CellEditor.EditTemplate>

             <!-- Declare the wanted key gesture that will activate the ShortTime CellEditor. -->
             <xcdg:CellEditor.ActivationGestures>
                <xcdg:TextInputActivationGesture />
             </xcdg:CellEditor.ActivationGestures>
          </xcdg:CellEditor>


    André
    Software Developer and Tech Support
    Xceed Software Inc.
  •  12-04-2008, 12:19 PM Post no. 17352 in reply to 17241

    Re: Setting Min Date and Max Date for DatePicker Control

    André:
    This is not possible, since there are no Min/MaxDate properties in the DatePicker at the moment.

    Are there any plans to introduce a MinDate property?  Some customers occasionally enter a year of 0000 for whatever reason and an out of range exception is thrown because it is not between 1 and 9999.  There doesn't seem to be an easy way to handle it either due to the current restrictions of the control.  Unless, of course, you have any suggestions. 

  •  12-17-2008, 3:29 PM Post no. 17536 in reply to 17352

    Re: Setting Min Date and Max Date for DatePicker Control

    We have added this to our feature request list, so it may be added in a future version.


    André
    Software Developer and Tech Support
    Xceed Software Inc.
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.