翻譯|使用教程|編輯:龔雪|2020-12-17 10:01:12.473|閱讀 425 次
概述:在本文中,主要為大家介紹如何進(jìn)行WPF Scheduler控件的遷移。DevExpress WPF v20.2目前正式支持.NET 5.0,歡迎下載新版體驗!
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關(guān)鏈接:
下載DevExpress v20.2完整版 DevExpress v20.2漢化資源獲取
通過DevExpress WPF Controls,您能創(chuàng)建有著強大互動功能的XAML基礎(chǔ)應(yīng)用程序,這些應(yīng)用程序?qū)W⒂诋?dāng)代客戶的需求和構(gòu)建未來新一代支持觸摸的解決方案。
在下載并安裝新的Scheduler Control后,技術(shù)團(tuán)隊針對WPF的性能和開發(fā)范例對產(chǎn)品進(jìn)行了優(yōu)化。
下表有助于總結(jié)新的Scheduler與舊的Scheduler之間的區(qū)別,性能已經(jīng)得到了很大的提升。
從提高的渲染速度到快速的滾動和記錄加載,新的WPF Scheduler在設(shè)計時考慮了最困難的性能用例。
與舊版本不同,新的WPF Scheduler 是為了充分利用MVVM和WPF自定義(模板,樣式)而構(gòu)建的。 開始使用新的Scheduler后,您會發(fā)現(xiàn)可以完全控制其視圖模型(單元格/約會選擇、約會編輯等),并使用標(biāo)準(zhǔn)WPF方法自定義控件。
以下遷移指南可以幫助您將項目從較舊的項目遷移到新的Scheduler Control。
項目參數(shù)和命名空間:
刪除對DevExpress.Xpf.Scheduler.v17.2.dll程序集的引用,添加對DevExpress.Xpf.Scheduling.v17.2.dll程序集的引用。
將
XAML
xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduler"
更改為
XAML
xmlns:dxsch="http://schemas.devexpress.com/winfx/2008/xaml/scheduling"
在新的Scheduler中Week view類似于以前的,在新的Scheduler中,以前的 沒有等效功能。
具有默認(rèn)設(shè)置的所有視圖類型都可以“開箱即用”,但是在在XAML中,您可以指定任意數(shù)量的具有不同類型和設(shè)置的視圖。所有視圖都包含在集合中,激活視圖由 屬性指定。
屬性允許最終用戶確定在切換視圖時單擊哪個菜單項。
如以下代碼示例所示,指定了視圖屬性:
XAML
<dxsch:SchedulerControl> <dxsch:DayView x:Name="dayViewOne" Caption="DayView One" ResourcesPerPage="5" ShowAllDayArea="False" ShowWorkTimeOnly="True" SnapToCellsMode="Never" TimeScale="00:10:00" /> <dxsch:DayView x:Name="dayViewTwo" Caption="DayView Two" ResourcesPerPage="5" ShowAllDayArea="False" ShowWorkTimeOnly="True" SnapToCellsMode="Never" TimeScale="00:10:00" /> <dxsch:WorkWeekView x:Name="workWeekView" Caption="My View" ResourcesPerPage="5" ShowAllDayArea="False" ShowWorkTimeOnly="True" SnapToCellsMode="Never" TimeScale="00:10:00" /> <dxsch:WeekView x:Name="weekView" ResourcesPerPage="5" ShowAllDayArea="False" ShowWorkTimeOnly="True" SnapToCellsMode="Never" TimeScale="00:10:00" /> <dxsch:MonthView x:Name="monthView" WeekCount="4" /> </dxsch:SchedulerControl>
使用 對象替代對象進(jìn)行數(shù)據(jù)綁定,使用標(biāo)準(zhǔn)WPF綁定將數(shù)據(jù)源綁定到SchedulerControl,綁定的數(shù)據(jù)源需要Appointment和資源映射。
映射名稱具有以下差異:
標(biāo)簽和狀態(tài)可以使用和屬性以與Appointments和Resources相同的方式存儲在數(shù)據(jù)源中并進(jìn)行綁定。 在這種情況下,需要標(biāo)簽和狀態(tài)映射。
下面的代碼示例演示Scheduler,其調(diào)度和資源已綁定到數(shù)據(jù)上下文。該代碼為 Note 字段指定了通用映射和自定義映射。
XAML
<dxsch:SchedulerControl.DataSource> <dxsch:DataSource AppointmentsSource="{Binding Appointments}" ResourcesSource="{Binding Resources}"> <dxsch:DataSource.AppointmentMappings> <dxsch:AppointmentMappings Start="StartTime" End="EndTime" AllDay="AllDay" Subject="Subject" Id="Id" Description="Description" LabelId="LabelId" Location="Location" RecurrenceInfo="RecurrenceInfo" Reminder="ReminderInfo" ResourceId="ResourceId" StatusId="StatusId" TimeZoneId="TimeZoneId" Type="Type"> <dxsch:CustomFieldMapping Mapping="Note" Name="Note" /> </dxsch:AppointmentMappings> </dxsch:DataSource.AppointmentMappings> <dxsch:DataSource.ResourceMappings> <dxsch:ResourceMappings Id="Id" Caption="Caption" /> </dxsch:DataSource.ResourceMappings> </dxsch:DataSource> </dxsch:SchedulerControl.DataSource>
類實例代表Appointment對象,使用以下成員可以訪問AppointmentItem集合:
最終用戶使用in-place編輯器或appointment編輯表單創(chuàng)建新的appointment時,將觸發(fā)SchedulerControl.InitNewAppointment事件,您可以處理此事件以修改新創(chuàng)建的appointment。
隨后,SchedulerControl.AppointmentsUpdated事件會觸發(fā),更改appointment時,將觸發(fā)SchedulerControl.AppointmentsUpdated事件。 您可以處理此事件,以將更改保存到外部數(shù)據(jù)源。但是它不提供有關(guān)已修改的appointment信息,更通用的事件是SchedulerControl.ItemPropertyChangedevent,它指示屬性更改以及約會、資源、狀態(tài)和標(biāo)簽的更新。
要訪問選定appointments的源對象,請使用SchedulerControl.SelectedAppointmentsSource方法。 使用SchedulerControl.GetAppointmentItemBySourceObject方法可通過其源對象獲取appointment。
SchedulerControl.GetAppointments方法返回指定時間間隔內(nèi)的所有約會,包括出現(xiàn)和異常。 若要確定遞歸鏈間隔,請分別使用AppointmentItem.QueryStart和AppointmentItem.QueryEnd屬性。您可以通過將遞歸鏈指定為指定的遞歸模式的異常來為遞歸鏈分配任何約會。
ResourceItem類實例代表Resource對象,可使用以下成員訪問ResourceItem集合:
若要獲取所選資源,請使用SchedulerControl.SelectedResource屬性。使用SchedulerControl.SelectedResourceSource方法來訪問所選資源背后的源對象,要通過其源對象獲取資源,請使用SchedulerControl.GetResourceItemBySourceObject方法。
資源不包含關(guān)聯(lián)的圖像,舊的Scheduler具有Resource.ImageBytes屬性,該屬性提供圖片以顯示在資源標(biāo)題中。此時,您應(yīng)該使用自定義字段來存儲和獲取圖像,因此需要自定義字段映射。
若要在資源標(biāo)題中顯示圖像(文本或任何控件),請創(chuàng)建一個自定義模板并將其分配給ViewBase.ResourceHeaderContentTemplate屬性。 此模板的DataContext是一個ResourceHeaderViewModel對象,該對象提供Resource和Interval屬性。您可以在Resource Header數(shù)據(jù)模板內(nèi)的綁定中使用這些屬性。
AppointmentLabelItem類實例表示約會的Label對象,可以使用SchedulerControl.LabelItems屬性訪問標(biāo)簽的集合。 您可以使用與約會和資源數(shù)據(jù)相同的方式將包含約會標(biāo)簽數(shù)據(jù)的數(shù)據(jù)源綁定到DataSource.AppointmentLabelSource。
AppointmentStatusItem類實例代表約會的Status對象,使用SchedulerControl.StatusItems屬性可以訪問狀態(tài)集合。 您可以用與約會和資源數(shù)據(jù)相同的方式將包含約會狀態(tài)數(shù)據(jù)的數(shù)據(jù)源綁定到DataSource.AppointmentStatusesSource。
ReminderItem類實例表示約會的提醒,其后代 - RecurringReminderItem類 - 提醒定期約會系列。可以使用Appointment.Reminders屬性訪問特定約會的提醒集合。 若要創(chuàng)建提醒,請使用AppointmentItem.CreateNewReminder方法,HasReminder屬性不再可用。
SchedulerControl.CheckTriggeredReminders方法立即調(diào)用所有警報以進(jìn)行過期約會,TriggeredReminder對象引用了觸發(fā)的提醒,該對象結(jié)合了ReminderItem,相關(guān)的AppointmentItem和警報時間。 使用SchedulerControl.TriggeredReminders屬性可以訪問TriggeredReminder對象的集合。
DevExpress技術(shù)交流群2:775869749 歡迎一起進(jìn)群討論
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都網(wǎng)