This repository has been archived by the owner on Oct 16, 2023. It is now read-only.
/
MainWindow.xaml.cs
38 lines (32 loc) · 1.69 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using System;
using System.Windows;
using DevExpress.Xpf.Scheduler;
using DevExpress.XtraScheduler;
namespace SchedulerCustomFieldWpf {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
SchedulerStorage schedulerStorage = schedulerControl1.Storage;
schedulerStorage.AppointmentStorage.CustomFieldMappings.Add(new SchedulerCustomFieldMapping("cfPrice", "Price"));
Appointment apt = schedulerStorage.CreateAppointment(AppointmentType.Normal);
apt.CustomFields["cfPrice"] = 10;
apt.Start = DateTime.Today.AddHours(1);
apt.End = DateTime.Today.AddHours(2);
apt.Subject = "Test";
schedulerStorage.AppointmentStorage.Add(apt);
schedulerControl1.Start = DateTime.Today;
schedulerControl1.DayView.TopRowTime = TimeSpan.Zero;
}
private void schedulerControl1_AppointmentViewInfoCustomizing(object sender, AppointmentViewInfoCustomizingEventArgs e) {
CustomAppointmentData cad = new CustomAppointmentData();
object price = e.ViewInfo.Appointment.CustomFields["cfPrice"];
if (price != null && price != DBNull.Value)
cad.Price = Convert.ToDecimal(price);
e.ViewInfo.CustomViewInfo = cad;
}
}
public class CustomAppointmentData : DependencyObject {
public static readonly DependencyProperty PriceProperty = DependencyProperty.Register("Price", typeof(decimal), typeof(CustomAppointmentData), new PropertyMetadata(0m));
public decimal Price { get { return (decimal)GetValue(PriceProperty); } set { SetValue(PriceProperty, value); } }
}
}