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

Manipulate multiple appointments in MVVM pattern

1 Answer 124 Views
ScheduleView
This is a migrated thread and some comments may be shown as answers.
Isto
Top achievements
Rank 1
Isto asked on 06 Mar 2015, 07:37 AM
Hi,

I am creating a wpf application with MVVM pattern. The application has a radscheduleview component with context menu attached to it. When user select the "Delete Note" menu item, how can I get all selected appointments into the list which I can then go through, and do desired manipulations to each appointment?

Currently I have a command which delete one appointment at a time. A new requirement is deletion of all selected appointments. Any ideas?

        public RelayCommand<CustomAppointment> DeleteNoteCommand
        {
            get
            {
                return deleteNoteCommand
                    ?? (deleteNoteCommand = new RelayCommand<CustomAppointment>(
                                          p =>
                                          {
                                              if (p != null)
                                              {
                                                  var message = new DialogMessage("Delete Note?", DeleteNoteCallback)
                                                  {
                                                      Button = MessageBoxButton.OKCancel,
                                                      Caption = "Delete Note",
                                                      Icon = MessageBoxImage.Warning
                                                  };
                                                  deletedNote = p; // global variable to send selected item to messenger
                                                  Messenger.Default.Send(message);
                                              }
                                          },
                                          p => (p != null) && (p.Source == NOTE));
            }
        }

1 Answer, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 10 Mar 2015, 04:21 PM
Hi Isto,

In order to achieve the desired behavior of RadMenuItem's Command and get all SelectedAppointments of RadScheduleView you could pass them as a CommandParamenter as shown below - thus you will be able to manipulate with these Appointments  as needed when the command is executed:

<telerik:RadMenuItem Header="Delete Note" Command="{Binding Source={StaticResource MyViewModel}, Path=DeleteAllSelectedAppointmentsCommand, Mode=TwoWay}"
                        CommandParameter="{Binding Path=Menu.UIElement.SelectedAppointments,RelativeSource={RelativeSource Self}}"/>

Hopes this helps.

Regards,
Nasko
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ScheduleView
Asked by
Isto
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Share this question
or