Show empty date value on load

4 posts, 0 answers
  1. Joe Bohen
    Joe Bohen avatar
    62 posts
    Member since:
    May 2009

    Posted 03 Nov 2015 Link to this post

    Hi,

     

    I have a RadDateTimePicker which is databound to a class object when my form loads I want to display and empty value in order that the watermark content is displayed. I also want to display a date range when the date time picker is selected and in order to do this I am setting the display range values when the main window is loaded. My problem is that I am seeing the default null value  01/01/0001 00:00:00!  How do I achieve this behavior 

     

    <telerik:RadDateTimePicker x:Name="DeldateTime" Width="160" TimeInterval="0:30:0" DateTimeWatermarkContent="Delivery Date\Time" SelectedValue="{Binding dtDeliverDate, Mode=TwoWay, NotifyOnValidationError=True, ValidatesOnDataErrors=True}" Height="26" VerticalAlignment="Bottom" ToolTip="Delivery date - Select both Day and Time values!" TabIndex="4" IsTabStop="True"  />

    Date range set on loaded event

    Me.DeldateTime.SelectableDateStart = DateTime.Now.AddMonths(-3)
    Me.DeldateTime.SelectableDateEnd = DateTime.Now.AddMonths(3)
    Me.DeldateTime.DisplayDate = DateTime.Now

    Property

    Public Property dtDeliverDate() As DateTime
            Get
                Return Me.m_dtDeliverDate
            End Get
            Set(value As DateTime)
                Me.m_dtDeliverDate = value
                If IsDate(m_dtDeliverDate) Then
                    Me.m_szDeliveryTime = Format(m_dtDeliverDate, "HH:mm")
                End If
                Me.SendPropertyChanged("dtDeliverDate")
            End Set
        End Property​

     

  2. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 05 Nov 2015 Link to this post

    Hi Joe,

    The observed by you behavior of RadDateTimePicker is caused by the SelectedValue property. Actually, you are binding it to a property of type DateTime and its initial and default value is "01/01/0001 00:00:00". 

    However, the SelectedValue property is actually of type DateTime?. So, by changing the type of the property to be DateTime? the watermark should be displayed as expected:
    Private m_dtDeliverDate As DateTime?
     
    Public Property DtDeliverDate() As DateTime?
        Get
            Return Me.m_dtDeliverDate
        End Get
     
        Set(ByVal value As DateTime?)
            If Not Me.m_dtDeliverDate.Equals(value) Then
                Me.m_dtDeliverDate = value
                Me.OnPropertyChanged(Function() Me.m_dtDeliverDate)
            End If
        End Set
    End Property

    Hope this helps.

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for WPF is Visual Studio 2017 Ready
  4. Joe Bohen
    Joe Bohen avatar
    62 posts
    Member since:
    May 2009

    Posted 08 Nov 2015 in reply to Nasko Link to this post

    Hi Nasko,

    Thank you for your reply, but I am a little confused by your suggestion that I set the value to a ​DateTime I was under the impression that I was already doing that!  Can you provide me with an example based on the information provided please.

    Regards,

    Joe

  5. Nasko
    Admin
    Nasko avatar
    587 posts

    Posted 09 Nov 2015 Link to this post

    Hello Joe,

    Attached you could find a sample project that demonstrates the described in my previous response approach? Could you please check it and let me know if I didn't miss something and that is the behavior you are looking for?

    If there is something missed could you please, modify the sample in order to reproduce your issue and send it back to us - thus we could be able to provide you with a prompt solution?

    We are looking forward to hearing from you.  

    Regards,
    Nasko
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top