MindFusion.Wpf Pack Programmer's Guide
Tutorial 3: Using the Standard Forms

This tutorial shows how to use the standard Scheduling for WPF dialogs to edit appointments in the calendar. This tutorial extends the application created in the previous tutorial so if you haven't done it already, complete Tutorial 2: Creating Recurrent Items first.

1. Add a reference to the dialogs assembly

In order to use the stock forms that come with Scheduling for WPF, add a reference to the assembly that contains them. To do so, open the Solution Explorer by selecting View -> Solution Explorer from the Visual Studio menu, then right-click on the 'References' item and select 'Add Reference' from the context menu. In the dialog that appears, navigate to the MindFusion.Scheduling.Wpf.StandardForms.dll file and click 'OK'. The file is usually located in the 'c:\Program Files\MindFusion\MindFusion.Scheduling for WPF' folder or in the folder where you have installed the product.

 Note

In Visual Basic projects check the 'Show All Files' button in the Solution Explorer toolbar in order for the References project item to appear.

2. Handling the ItemClick event

The appointment form is usually displayed in response to double-clicking the appointment. Switch to design view, select the control and in the Properties window click the 'Events' button located in the toolbar near the top of the window. Navigate to the ItemClick event in the event list and double-click it. This automatically creates an event handler for the event (with default name calendar_ItemClick) and places the input cursor at its beginning.

3. Display the form

To display the form add the following code to the body of the event handler just created.

 Note

Be sure to include both MindFusion.Scheduling and MindFusion.Scheduling.Wpf namespaces via the using (Imports in Visual Basic) keyword in the beginning of the file.

C#  Copy Code

// Display the form only if left mouse button is double-clicked
if (e.LeftButton != MouseButtonState.Pressed || e.Clicks != 2)
    return;

calendar.ResetDrag();

// Create the form
AppointmentForm form = new AppointmentForm(calendar.Schedule);
form.Title = e.Item.HeaderText;
form.SetAppointment(e.Item as Appointment);

// Display the form to the user
form.ShowDialog();

Visual Basic  Copy Code

' Display the form only if left mouse button is double-clicked
If e.LeftButton <> MouseButtonState.Pressed Or e.Clicks <> 2 Then Return

calendar.ResetDrag()

' Create the form
Dim form As New AppointmentForm(calendar.Schedule)
form.Title = e.Item.HeaderText
form.SetAppointment(CType(e.Item, Appointment))

' Display the form to the user
form.ShowDialog()

The form automatically updates the edited item with all modifications made by the user.

4. Build and run

Compile and run the application. Create an appointment by typing and then double-click it to display the appointment dialog.