Articles in this section
Category / Section

How to use SfSchedule commands?

2 mins read

Use of schedule command

You can use SfSchedule commands instead of Context Menu to perform the same operation. This article explains how to use the SfSchedule commands in the Schedule. The following Context Menu operations can be handled by using the SfSchedule commands.

1. Adding a new appointment

2. Editing appointments

3. Copy and Paste appointments

4. Deleting appointments

5. DragAndDrop

Using SfSchedule Commands:

1. Create a SilverLight application and add the SfSchedule control to it. Now create Buttons to perform the commands in the click event as shown in the following code example.

XAML

<UserControl.Resources>
        <Style TargetType="Button" >
            <Setter Property="Margin" Value="5"></Setter>
            <Setter Property="Background" Value="LightSlateGray"></Setter>
            <Setter Property="HorizontalAlignment" Value="Center"></Setter>
            <Setter Property="Width" Value="150"></Setter>
            <Setter Property="FontSize" Value="20"></Setter>
        </Style>
</ UserControl.Resources>
<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"></RowDefinition>
            <RowDefinition Height="0.1*"></RowDefinition>
        </Grid.RowDefinitions>
        <syncfusion:SfSchedule ScheduleType="Month" x:Name="schedule"></syncfusion:SfSchedule>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center">
            <Button Content="Add"  Name="add" Click="add_Click"></Button>
            <Button Content="Edit" Name="edit" Click="edit_Click"></Button>
            <Button Content="Delete"  Name="delete" Click="delete_Click" ></Button>
            <Button Content="Copy"  Name="copy" Click="copy_Click"></Button>
            <Button Content="Paste" Name="paste" Click="paste_Click_1" ></Button>
            <Button Content="DragAndDrop" Name="drag_drop" Click="drag_drop_Click"></Button>
        </StackPanel>
</Grid>

2. Now add the SfSchedule commands in the click event as follows.

C#

private void add_Click(object sender, RoutedEventArgs e)
{
   ScheduleCommands.AddNewCommand.Execute(this.schedule);
}
private void edit_Click(object sender, RoutedEventArgs e)
{
   ScheduleCommands.EditCommand.Execute(this.schedule);
}
private void copy_Click(object sender, RoutedEventArgs e)
{
   ScheduleCommands.CopyCommand.Execute(this.schedule);
}
private void paste_Click_1(object sender, RoutedEventArgs e)
{
   ScheduleCommands.PasteCommand.Execute(this.schedule);
}
private void delete_Click(object sender, RoutedEventArgs e)
{
   ScheduleCommands.DeleteCommand.Execute(this.schedule);
}        
private void drag_drop_Click(object sender, RoutedEventArgs e)
{
   ScheduleCommands.DragAndDropCommand.Execute(this.schedule);
}      

The following screenshots display the different SfSchedule command operations.

1. Adding a new appointment:

Click the Add button to add appointments in the Schedule.

Adding new appointment using Add button

Figure 1: Adding new appointment using Add button

Appointment created using Add button

Figure 2: Appointment created using Add button

2. Editing Appointments:

For editing the appointments, select any of the appointments in the Schedule and click the Edit button.

Editing appointments using edit button

Figure 3: Editing appointments using Edit button

3. Copy and Paste Appointments:

For copying appointments, select any of the appointments in the Schedule and click the Copy button. Then paste the appointment in Schedule using the Paste button.

 

Copy and paste appointments

Figure 4: Copy and Paste Appointments

4. Deleting Appointments:

For deleting appointments, select any of the appointments in the Schedule and click the Delete button.

Deleting appointments using delete button

Figure 5: Deleting appointments using Delete button

5. DragAndDrop

For doing DragAndDrop select any of the appointments in the Schedule and click DragAndDrop button.

Drag and drop the appointments

Figure 6: Drag and Drop the appointments

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied