最近在做一个会议登记模块,需要用到SchedulerControl控件,一些学习心得在这里记录下。
自定义appointment窗口
1.新建SchedulerControl1_EditAppointmentFormShowing事件,
{
e.Form = new CustomAppointmentForm(this.schedulerControl1, e.Appointment);//CustomAppointmentForm可以是自己任意新建窗口。
e.AllowResize = false;
}
2.CustomAppointmentForm后台需要添加类CustomAppointmentForm
1 public class CustomAppointmentFormController : AppointmentFormController 2 { 3 public CustomAppointmentFormController(SchedulerControl control, Appointment apt): base(control, apt) 4 { 5 } 6 public event PropertyChangedEventHandler ProperyChanged; 7 8 protected override void ApplyChangesCore() 9 { 10 base.ApplyChangesCore(); 11 } 12 13 }
3.CustomAppointmentForm添加构造函数
1 public CustomAppointmentForm(SchedulerControl control, Appointment apt) 2 { 3 if (control == null || apt == null) 4 throw new ArgumentNullException("control"); 5 if (control == null || apt == null) 6 throw new ArgumentNullException("apt"); 7 8 this.control = control; 9 this.controller = new CustomAppointmentFormController(control, apt); 10 this.apt = apt; 11 //dateEdit1.DateTime = Convert.ToDateTime (a); 12 //dateEdit1.Text = a; 13 dateEdit1.EditValue = DateTime.Now.TimeOfDay; 14 InitializeComponent(); 15 }
4.实例化刚才定义类同时定义所需属性
1 SchedulerControl control; 2 CustomAppointmentFormController controller; 3 Appointment apt; 4 public CustomAppointmentFormController Controller { get { return controller; } } 5 public SchedulerControl Control { get { return control; } } 6 public Appointment Appointment { get { return apt; } }
5.前台开始进行新建窗口与SchedulerControl控件属性的绑定。(使用binding)
1 <TextBlock x:Name="label5" Margin="0,0,4,4" 2 HorizontalAlignment="Left" 3 Grid.Row="1" Grid.Column="0" 4 Text="开始时间:" /> 5 <dxe:DateEdit x:Name="dateStart" Margin="0,0,4,4" 6 Grid.Row="1" Grid.Column="1" 7 EditValue="{Binding Controller.DisplayStartDate, Mode=TwoWay}"/> 8 <dxe:ButtonEdit x:Name="timeStart" Margin="0,0,0,4" 9 Grid.Row="1" Grid.Column="2" 10 AllowDefaultButton="False" 11 MaskType="DateTime" DisplayFormatString="{Binding TimeEditMask}" 12 Mask="{Binding TimeEditMask}" 13 EditValue="{Binding Controller.DisplayStartTime, Converter={StaticResource timeSpanToDateTimeConverter}, Mode=TwoWay}" 14 IsEnabled="{Binding IsChecked, Converter={StaticResource ResourceKey=invertedBoolConverter}, ElementName=chkAllDay}"/>
时间: 2024-10-11 11:55:52