DateTimeWatermarkContent doesn't work if SelectedValue is bound?

2 posts, 0 answers
  1. Rob Ainscough
    Rob Ainscough avatar
    172 posts
    Member since:
    Jan 2010

    Posted 02 Oct 2012 Link to this post

    I'm having a hard time trying to display my DateTimeWatermarkContent when my control's SelectedValue is bound to an object (MVVM).

    The problem is that my object's property is a Date type and even when set to "Nothing" it always displays "1/1/0001".

    So I'm not sure how DateTimeWatermarkContent could work when SelectedValue is bound to anything??

    Any hints?  

    Thanks, Rob
  2. Rob Ainscough
    Rob Ainscough avatar
    172 posts
    Member since:
    Jan 2010

    Posted 02 Oct 2012 Link to this post

    Nevermind found the solution, I need to make sure the MVVM class property (Date) was Nullable:

    Example:

    Private _AdjustedRRExpires As Nullable(Of Date)
    Public Property AdjustedRRExpires() As Nullable(Of Date)
        Get
            Return _AdjustedRRExpires
        End Get
        Set(ByVal value As Nullable(Of Date))
            _AdjustedRRExpires = value
            OnPropertyChanged(New PropertyChangedEventArgs("AdjustedRRExpires"))
        End Set
    End Property

    Assume dataContext binding has been done -- XAML 

    <telerik:RadDatePicker x:Name="RRAdjustmentExpiresDatePicker" SelectedValue="{Binding Path=AdjustedRRExpires}" DisplayFormat="Short" DateTimeWatermarkContent="Never" Grid.Column="1" Grid.Row="1" Style="{StaticResource DCRadDatePicker}" />
  3. DevCraft banner
Back to Top