Change Date via MVVM

2 posts, 1 answers
  1. Tim
    Tim avatar
    41 posts
    Member since:
    Oct 2012

    Posted 13 Feb 2013 Link to this post

    I have a RadListBox bound to an ObservableCollection<RelatedSA>. RelatedSA has a date property and when the selected item changes on the RadListBox, I want to have the ScheduleView go to that date. I have the following bound to the SelectedItem of my RadListBox.

    private RelatedSA selectedAppointment;
            public RelatedSA SelectedAppointment
                    return selectedAppointment;
                    if (value != selectedAppointment)
                        selectedAppointment = value;
                        DateTime apptDate = selectedAppointment.ServiceDate;
                        // change calendar date
                        DateSpan ds = new DateSpan();
                        ds.Start = new DateTime(apptDate.Year, apptDate.Month, apptDate.Day);
                        ds.End = ds.Start.AddDays(1);
                        CurrentVisibleDateRange = ds;

    The ScheduleView is not changing dates when I select an item in the RadListBox. What do I need to do for this to happen? I am using MVVM.

  2. Answer
    Yana avatar
    5043 posts

    Posted 18 Feb 2013 Link to this post

    Hello Tim,

    I would suggest to set CurrentDate property of the ScheduleView instead of VisibleRange. You could even bind it directly to the SelectedItem of the ListBox:

    <telerik:RadListBox x:Name="ListBox1"
        ItemsSource="{Binding DateTimeItems}"/>
    <telerik:RadScheduleView x:Name="ScheduleView" Grid.Row="1"
                AppointmentsSource="{Binding Appointments}"
                CurrentDate="{Binding SelectedItem, ElementName=ListBox1}">        

    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top