dataManager.DialogFactory = New MyScheduleDialogFactory()
This topic explains the user activity dialogs of the xamSchedule controls and demonstrates how to create custom dialogs.
The topic is organized as follows:
Introduction
Built-In Dialogs
Custom Dialogs
Specifying a Custom Dialog
Code Example
Customizing Existing Dialogs
Methods Used
Reverting to Built-In Dialogs
Providing the Contents of a Custom Dialog
"Lightweight" and "Full-Featured" Dialogs
Example Lightweight and Full-Featured Dialogs
Switching Full-Featured and Lightweight Dialogs
Activity Recurrence Dialog
Displaying Dialogs
Related Topics
Infragistics xamSchedule controls provide robust support for dialog-based user interaction. Standard ‘built-in’ dialogs are available, as well as the capability for creating custom dialogs.
The standard built-in dialogs are defined in the xamSchedule controls assembly and are available without referencing any additional assemblies. These dialogs are designed to be efficient in terms of resource use and, as such, do not reference any additional external assemblies to display their user interface (UI), although xamSchedule does provide a mechanism for using custom dialogs that reference other assemblies which contain the needed controls and/or functionality.
Table 1 lists the built-in dialogs provided with xamSchedule and the possible user interactions in them.
The control architecture allows the developer to specify custom dialogs that should be used by the xamSchedule controls in place of any of the above built-in dialogs. To supply a custom dialog:
First, create a class which inherits from ScheduleDialogFactoryBase and override one or more methods to supply the dialog(s) you would like to replace.
Next, set the DialogFactory property on the XamScheduleDataManager to an instance of your derived class.
In Visual Basic:
dataManager.DialogFactory = New MyScheduleDialogFactory()
In C#:
dataManager.DialogFactory = new MyScheduleDialogFactory();
Note:
To revert to using the built-in dialogs, simply set the dataManager.DialogFactory property to null.
Custom versions of specific dialogs can be implemented with the abstract ScheduleDialogFactoryBase class which exposes a number of virtual methods that you can override. (Table 2)
To supply a custom dialog for editing Appointments:
Create a ScheduleDialogFactory derived class as in this sample code:
In Visual Basic:
Public Class MyCustomScheduleDialogFactory
Inherits ScheduleDialogFactoryBase
Public Overrides ReadOnly Property SupportedActivityDialogTypes() _
As ActivityTypes
Get
Return ActivityTypes.Appointment
End Get
End Property
Public Overrides Function CreateActivityDialog(container As _
FrameworkElement, dataManager As XamScheduleDataManager, _
activity As ActivityBase, allowModifications As Boolean, _
allowRemove As Boolean) As FrameworkElement
Select Case activity.ActivityType
Case ActivityType.Appointment
If True Then
' Create the element that represents
' the contents of the dialog
Return GetMyCustomDialog()
End If
Case Else
If True Then
' Return null for unsupported activity types.
Return Nothing
End If
End Select
End Function
End Class
In C#:
public class MyCustomScheduleDialogFactory : ScheduleDialogFactoryBase
{
public override ActivityTypes SupportedActivityDialogTypes
{
get { return ActivityTypes.Appointment; }
}
public override FrameworkElement CreateActivityDialog(
FrameworkElement container,
XamScheduleDataManager dataManager,
ActivityBase activity,
bool allowModifications,
bool allowRemove)
{
switch (activity.ActivityType)
{
case ActivityType.Appointment:
{
// Create the element that represents
// the contents of the dialog
return GetMyCustomDialog();
}
default:
{
// Return null for unsupported activity types.
return null;
}
}
}
}
To revert to using the built-in dialogs, simply set the XamScheduleDataManager DialogFactory property to null.
In the example above, the code calls a method named GetMyCustomDialog(). The name of the method is at your discretion. You need to create and return a FrameworkElement derived class that represents the contents of your custom dialog. You have two basic options in terms of what element you return:
Return a Window that is appropriate for the platform on which your application will run (i.e., Silverlight, WPF or WPF/XBAP) which contains all the elements necessary to display the user interface (UI) of your custom dialog.
Return any non-window FrameworkElement-derived class containing the dialog’s elements and xamSchedule will take care of hosting it in a top-level window that is appropriate for the platform on which your application will run.
If you are creating a custom dialog as a replacement for the Appointment or ActivityRecurrence dialogs, you may want to consider using the AppointmentDialogCore and/or ActivityRecurrenceDialogCore classes to reduce the amount of work required to fully implement these fairly complex dialogs. These two classes are derived from Control and implement the majority of the functionality contained in each dialog.
Note:
The references to AppointmentDialogCore in the following paragraphs also apply to TaskDialogCore and JournalDialogCore. All three classes are derived from the abstract base class ActivityDialogCore which contains the logic for the common behaviors and features that are supported by all three dialogs.
In the case of AppointmentDialogCore, the default Style for this control includes all the dialog elements contained in the built-in Appointment dialog except the Ribbon (although it does expose a NavigationControlSite property of type ContentControl where you can place a navigation control like a Ribbon). In the case of ActivityRecurrenceDialogCore, the default Style for this control includes all the dialog elements contained in the built-in ActivityRecurrenceDialog.
There two ways you can make use of these controls. One approach would be to create an instance of one of the Core classes in your custom dialog and add other dialog elements around it. An alternative approach involves creating a Style that formats the control to suit your needs.
The primary benefit of using the controls is to take advantage of the exposed view model properties that you can bind to from within your template in addition to commands that handle common dialog scenarios. The commands exposed by the controls include:
ActivityDialogCore commands (apply to all three activity dialogs - AppointmentDialogCore, TaskDialogCore, JournalDialogCore):
ActivityDialogCoreSaveAndCloseCommand – saves the modified Activity data using the appropriate XamScheduleDataManager data edit methods (i.e., BeginEdit, EndEdit, CancelEdit) to properly update your data source, and closes the dialog
ActivityDialogCoreCloseCommand – prompts the user with save options if necessary and then closes the dialog
ActivityDialogCoreDisplayRecurrenceDialogCommand – displays the ActivityRecurrenceDialog for the Appointment being edited
ActivityDialogCoreShowTimeZonePickersCommand – sets the AppointmentDialogCore. TimeZonePickerVisibility property which controls in your template can bind
ActivityDialogCoreHideTimeZonePickersCommand – sets the AppointmentDialogCore.TimeZonePickerVisibility property which controls in your template can bind
ActivityRecurrenceDialogCore commands:
RecurrenceDialogCoreSaveAndCloseCommand – saves the modified Recurrence data into the Appointment being edited
RecurrenceDialogCoreCloseCommand – discards the modified Recurrence data and closes the dialog
RecurrenceDialogCoreRemoveRecurrenceCommand – removes the Recurrence data from the Appointment being edited (resulting in a non-recurring Appointment) and closes the dialog
To minimize the impact of the built-in activities (appointments, tasks, journals) dialogs on the footprint of the xamSchedule controls, they are designed in a way that does not require references to or loading of other assemblies that contain additional controls.
In the case of the activities dialogs which typically contain a ribbon control, the built-in version of the dialogs includes a custom "simulated" ribbon that has the basic look and functionality of a "real" ribbon control (e.g., XamRibbon) but without advanced features like Application Menu, Quick AccessToolbar, collapsing RibbonGroups, etc. As a result, no additional assemblies are required when using the built-in Appointment, Task, and Journal dialogs.
The activities dialogs with this simulated ribbon are sufficient for most applications – particularly those that place value on reducing the number of assemblies that must be loaded at runtime.
To address the needs of applications that require full featured ribbon activities dialogs, xamSchedule includes a "full-featured" version of the dialogs that uses a XamRibbon control in the dialog’s UI instead of the simulated ribbon control used in the built-in "lightweight" Appointment dialog. Following are examples of the lightweight and full-featured versions of the dialogs.
In Visual Basic:
dataManager.DialogFactory = Nothing
In C#:
dataManager.DialogFactory = null;
This version of the Activities dialogs uses a XamRibbon control and is supplied in a separate NuGet package:
Infragistics.WPF.Schedules.Dialogs
To use the full-featured activities dialogs add a reference to the appropriate NuGet package in your project and set the XamScheduleDataManager DialogFactory property as follows:
In Visual Basic:
dataManager.DialogFactory = _
New Infragistics.Controls.Schedules.ScheduleDialogFactory()
In C#:
dataManager.DialogFactory =
new Infragistics.Controls.Schedules.ScheduleDialogFactory();
Note:
The "full featured" Appointment dialog assembly is implemented using the standard ScheduleDialogFactoryBase derived class approach outlined above for your custom dialogs.
The activity recurrence dialog is shown when the user presses the "Recurrence" button in any type of activity dialogs:
The activity recurrence dialogs can show a recurrence description as highlighted on the picture below:
The visibility of the recurrence description can be configured using the following procedure:
create a string resource in an existing or new resource file (.resx file) in your project
set the string resource’s name to "DLG_Recurrence_ShouldShowRecurrenceDescription"
set the string resource’s value to "true" or " depending of your visibility requirement
include the following line(s) in the constructor of your main window before the "InitializeComponent()" call (by registering this resource on any xamSchedule’s view all recurrence dialogs will by affected):
In Visual Basic:
XamDayView.RegisterResources("NameSpace.ResourceClassName", GetType(MainWindow).Assembly)
In C#:
XamDayView.RegisterResources("NameSpace.ResourceClassName", typeof(MainWindow).Assembly);
Note:
Replace "Namespace" with the namespace where your resource file is located, replace "ResourceClassName" with the name of your resource file and replace "MainWindow" with the name of your main window’s class name.
Note:
By default when using English, German or French languages the recurrence description is visible and when using Spanish or Japanese languages it is not visible.
The xamSchedule controls will automatically display the various dialogs described in this topic based on the user interaction with the controls (like when the user double-clicks a timeslot in the xamDayView control). As a result, you do not need to write code to ensure that the dialogs are displayed during the normal interaction with the xamSchedule controls.
However, if your application needs to display the dialogs based on interactions with other parts of your application’s UI, there is a way to display them manually. For displaying the dialogs, the following methods of the XamScheduleDataManager class can be used: