Full Customization

2 posts, 0 answers
  1. Tejas
    Tejas avatar
    4 posts
    Member since:
    Jan 2012

    Posted 23 Jan 2012 Link to this post

    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).

  2. Scott
    Scott avatar
    8 posts
    Member since:
    Aug 2011

    Posted 23 Jan 2012 Link to this post

    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.

  3. DevCraft banner
Back to Top