Note
The information in this topic applies to DevExpress ASP.NET Scheduler version 17.2 and later.
The View Model API enables you to customize dialog element characteristics (values, availability, and layout) as needed, without needing to override the ASPxScheduler‘s commands and copying the dialog form templates (UserControls) to your project.
This topic covers several common scenarios on how to customize the Appointment Dialog’s content and layout using the View Model API. In most cases, the ViewModel.PrepareControlFor and ViewModel.PrepareControl methods are used to access the Appointment Dialog editors.
The following code snippets illustrate how to customize editors on the form:
Replacing all Toggle editors with Check Boxes
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControl((ASPxCheckBox cb) => {
cb.ToggleSwitchDisplayMode = ToggleSwitchDisplayMode.Never;
});
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControl(Sub(cb As ASPxCheckBox)
cb.ToggleSwitchDisplayMode = ToggleSwitchDisplayMode.Never
End Sub)
Changing the “Start” and “End” editors’ DateTime format
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(m => m.StartTime, (ASPxDateEdit de) => {
de.EditFormat = EditFormat.Custom;
de.EditFormatString = "dd - MM - yyyy";
});
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(m => m.EndTime, (ASPxDateEdit de) => {
de.EditFormat = EditFormat.Custom;
de.EditFormatString = "dd - MM - yyyy";
});
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(Function(m) m.StartTime, Sub(de As ASPxDateEdit)
de.EditFormat = EditFormat.Custom
de.EditFormatString = "dd - MM - yyyy"
End Sub)
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(Function(m) m.EndTime, Sub(de As ASPxDateEdit)
de.EditFormat = EditFormat.Custom
de.EditFormatString = "dd - MM - yyyy"
End Sub)
Changing the “Resource” editor caption
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(m => m.ResourceIds, (ASPxEdit de) => {
de.Caption = "Employee";
});
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(Function(m) m.ResourceIds, Sub(de As ASPxEdit)
de.Caption = "Employee"
End Sub)
Changing the “Subject” editor caption’s forecolor and font settings
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(m => m.Subject, (ASPxTextBox de) => {
de.CaptionStyle.ForeColor = Color.Red;
de.CaptionStyle.Font.Bold = true;
});
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(Function(m) m.Subject, Sub(de As ASPxTextBox)
de.CaptionStyle.ForeColor = Color.Red
de.CaptionStyle.Font.Bold = True
End Sub)
Changing the “Description” editor’s forecolor and font settings.
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(m => m.Description, (ASPxMemo me) => {
me.ForeColor = Color.Blue;
me.Font.Bold = true;
me.Font.Italic = true;
});
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.PrepareControlFor(Function(m) m.Description, Sub([me] As ASPxMemo)
[me].ForeColor = Color.Blue
[me].Font.Bold = True
[me].Font.Italic = True
End Sub)
Hiding the “Location” and “All-Day” editors
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.SetItemVisibilityCondition("Location", false);
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.SetItemVisibilityCondition(vm => vm.IsAllDay, false);
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.SetItemVisibilityCondition("Location", False)
ASPxScheduler1.OptionsForms.DialogLayoutSettings.AppointmentDialog.ViewModel.SetItemVisibilityCondition(Function(vm) vm.IsAllDay, False)
See Also