Telerik RadDatePicker SelectableDateStart Binding value in c#

323 Views Asked by At

The SelectedDateStart needs to be bound to a date value set by another DatePicker. Can I get an example of binding the date in a string in C# to the xaml datePicker SelectedDateStart Property? This is what i have so far for the xaml

<telerik:RadDatePicker IsInputRestrictedToSelectableDates="True" 
                                       SelectableDateStart="{Binding Path=SetDepartureStartDate,Mode=TwoWay}"
                                       SelectedDate="{Binding Path=ActualDepartureDateLocal, Mode=TwoWay}"  
                                       IsEnabled="{Binding Path=IsActualDepartureDateTimeEditable}" 
                                       TabIndex="7" >
                </telerik:RadDatePicker>
1

There are 1 best solutions below

0
On

Figured it out!

SelectableDateStart="{Binding Path=SelectableDate}"

Used a bind and path that is on the date picker below.

 <telerik:RadDatePicker 
                    SelectedDate="{Binding Path=ActualDepartureDateLocal, Mode=TwoWay}"  IsEnabled="{Binding Path=IsActualDepartureDateTimeEditable}" TabIndex="7"  SelectableDateStart="{Binding Path=SelectableDate}" >
                    <i:Interaction.Behaviors>
                        <commanding:UpdateBindingSourceWhenRadDateTimeControlTextChanged/>
                    </i:Interaction.Behaviors>
                </telerik:RadDatePicker>

The bind path was then connnected to a DateTime in my cs file. The issue I was having is that the binding wasn't connected to my DataContext for teh cs file and wasn't returning a DateTime but a string. Switched these and it worked!

public DateTime SelectableDate
    {
        get
        {
            if (_loadStopToComplete.Actual_Arrival_Local != null)
            {
                _selectedDate = _loadStopToComplete.Actual_Arrival_Local.Value.Date;
                DepartureDate = Convert.ToString(_loadStopToComplete.Actual_Arrival_Local.Value.Date);
            }
            return _selectedDate;
        }
    }