对代码隐藏(DevExpress 计划程序控件)上的约会应用重复周期



我正在使用devExpress调度程序控件。请注意,我试图在以下代码上实现的是向代码隐藏上的约会添加递归。在此示例中,我在创建新约会时执行此操作。

我的窗口由调度程序控件组成:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525"
        xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler">
    <dxsch:SchedulerControl Name="schedulerControl1" />
</Window>

代码隐藏包括:

using System.Windows;
using DevExpress.XtraScheduler;
namespace WpfApplication1
{
    public partial class MainWindow : Window
    {
        public MainWindow() // Constructor
        {
            InitializeComponent();
            this.Loaded += new RoutedEventHandler(MainWindow_Loaded);
        }
        void MainWindow_Loaded(object sender, RoutedEventArgs e) // Fires when window loads
        {
            schedulerControl1.Storage.AppointmentsInserted += new PersistentObjectsEventHandler(Storage_AppointmentsInserted);
        }
        void Storage_AppointmentsInserted(object sender, PersistentObjectsEventArgs e) // fires when a new appointment is added
        {
            Appointment addedAppointment = null;
            foreach (Appointment item in e.Objects)
                addedAppointment = item;
            /*
                I want to set the reinsurance info in here!
                I cant because RecuranceInfo = null!                  
            */
            addedAppointment.RecurrenceInfo.Type = RecurrenceType.Hourly; // <- App Crashes
        }               
    }
}

我不想绑定控件的递归属性。

换句话说,如果我能创建一个从今天下午 2 点开始并每天重复且没有结束日期的约会,那就太好了。我怎样才能在代码隐藏上创建该约会?

答案在此链接中:http://documentation.devexpress.com/#WindowsForms/CustomDocument6201

基本上我必须做:

        Appointment apt = schedulerControl1.Storage.CreateAppointment(AppointmentType.Pattern);
        apt.Start = DateTime.Now;
        apt.End = apt.Start.AddHours(2);
        apt.Subject = "My Subject";
        apt.Location = "My Location";
        apt.Description = "My Description";
        apt.RecurrenceInfo.Type = RecurrenceType.Daily;
        schedulerControl1.Storage.AppointmentStorage.Add(apt);

相关内容

最新更新