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

Full Customization

1 Answer 68 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Tejas
Top achievements
Rank 1
Tejas asked on 23 Jan 2012, 08:29 AM
I want to have full control over all the Operation throughout whole Life Cycle. How can I get Currently Selected Appointment in ViewModel.
I tried to bind SelectedAppointment in my ViewModel. But It gets set once when It first initializes. Is there any way I can be notified when Appointment Selection Changed in my ViewModel. Actually I want it when Double Click happens on ScheduleView Control  so that I can have Currently Selected Appointment Object -  (null if New or object if existing).

1 Answer, 1 is accepted

Sort by
0
Scott
Top achievements
Rank 2
answered on 23 Jan 2012, 09:49 PM
From what I understand you want to capture the Appointment into an object in your view model by double clicking the appointment on the scheduler and not display the appointment edit dialog on the double click which is the default behavior?

If this is what you want to do you will want to use MVVMLight's EventToCommand by defining an Event Trigger on AppointmentEditing and binding that to the Command object in your model view, and disable the showdialog of radscheduleview.

So your xaml would look like this defined in your RadScheduleView:
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity" 
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.SL4"

<telerik:RadScheduleView .....>
<i:Interaction.Triggers>
<i:EventTrigger EventName="AppointmentEditing">
<cmd:EventToCommand Command="{Binding AppointmentEditCommand}" 
CommandParameter
="{Binding SelectedAppointment, ElementName=<Name of your RadScheduleView>}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</telerik:RadScheduleView>



In your Code behind you will want to disable the Appointment Editing dialog from appearing:



private void RadScheduleView_ShowDialog(object sender, ShowDialogEventArgs e)
        {
            if (e.DialogViewModel is AppointmentDialogViewModel)
                e.Cancel = true;
        }

In your View model you'll have something like the following:
public DelegateCommand AppointmentEditCommand { getprivate set; }

In your constructor of your view model:
AppointmentEditCommand = new DelegateCommand(AppointmentEditAction);



















And in your edit action:
void AppointmentEditAction(object o)
        {

}

Object o will be your selected appointment you can store this to a collection, singleton, or however you want to use it.

Hopefully this helps you get an idea of what you want to do.

Tags
ScheduleView
Asked by
Tejas
Top achievements
Rank 1
Answers by
Scott
Top achievements
Rank 2
Share this question
or