This is a migrated thread and some comments may be shown as answers.

DateTimeWatermarkContent doesn't work if SelectedValue is bound?

1 Answer 68 Views
DateTimePicker
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rob Ainscough
Top achievements
Rank 1
Rob Ainscough asked on 02 Oct 2012, 08:32 PM
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

1 Answer, 1 is accepted

Sort by
0
Rob Ainscough
Top achievements
Rank 1
answered on 02 Oct 2012, 09:01 PM
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}" />
Tags
DateTimePicker
Asked by
Rob Ainscough
Top achievements
Rank 1
Answers by
Rob Ainscough
Top achievements
Rank 1
Share this question
or