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

Change Date via MVVM

1 Answer 58 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 13 Feb 2013, 06:52 PM
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
        {
            get
            {
                return selectedAppointment;
            }
            set
            {
                if (value != selectedAppointment)
                {
 
                    selectedAppointment = value;
                    OnPropertyChanged("SelectedAppointment");
 
                    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;
 
                    VisibleRangeExecuted(CurrentVisibleDateRange);
                     
                }
            }
        }

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.

Thanks

1 Answer, 1 is accepted

Sort by
0
Accepted
Yana
Telerik team
answered on 18 Feb 2013, 11:47 AM
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}">        
</telerik:RadScheduleView>


Greetings,
Yana
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
ScheduleView
Asked by
Tim
Top achievements
Rank 1
Answers by
Yana
Telerik team
Share this question
or