SuperAPI AI 工具集

syncfusion-winui-scheduler

办公与效率

查看项目

更新于 10-16 02:16

技能介绍

用途

Syncfusion WinUI Scheduler(SfScheduler)是一个日历与排程控件,用于在 WinUI 桌面应用中显示预约,并允许用户创建、编辑和管理预约。适合构建日程表、会议预约、资源排期、时间管理类界面。

组件标识:

  • 包:Syncfusion.Scheduler.WinUI
  • 命名空间:Syncfusion.UI.Xaml.Scheduler
  • 类:SfScheduler

主要能力

  • 8 个内置视图:Day、Week、WorkWeek、TimelineDay、TimelineWeek、TimelineWorkWeek、TimelineMonth、Month。
  • 预约管理:通过内置编辑器创建、编辑、删除预约。
  • 拖放:通过直观的拖放重新安排预约。
  • 重复事件:支持每日、每周、每月、每年重复模式及例外。
  • 资源分组:按资源(人员、房间、设备)分组预约。
  • 时区支持:处理跨多个时区的预约。
  • 无障碍:完整键盘导航、屏幕阅读器支持、WCAG 合规。
  • 本地化:支持全球日期/时间格式与文化。
  • 主题:Fluent Design System,含 Light、Dark、HighContrast 主题。
  • 按需加载:针对大量预约数据集的性能优化。
  • 上下文菜单:内置且可自定义的上下文菜单。
  • 提醒:预约提醒通知。

使用方式(最小示例)

XAML:

<Window
    x:Class="SchedulerApp.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:scheduler="using:Syncfusion.UI.Xaml.Scheduler">

    <Grid>
        <scheduler:SfScheduler x:Name="Schedule"
                              ViewType="Week"
                              FirstDayOfWeek="Monday" />
    </Grid>
</Window>

C#:

using Syncfusion.UI.Xaml.Scheduler;
using System;

namespace SchedulerApp
{
    public sealed partial class MainWindow : Window
    {
        public MainWindow()
        {
            this.InitializeComponent();

            var appointments = new ScheduleAppointmentCollection();

            appointments.Add(new ScheduleAppointment
            {
                StartTime = DateTime.Now.Date.AddHours(10),
                EndTime = DateTime.Now.Date.AddHours(12),
                Subject = "Team Meeting",
                Location = "Conference Room A",
                Notes = "Discuss Q1 goals"
            });

            Schedule.ItemsSource = appointments;
        }
    }
}

关键属性

  • ViewType(SchedulerViewType):设置视图类型(Day、Week、Month、Timeline 变体)。
  • ItemsSource(IEnumerable):预约数据源。
  • DisplayDate(DateTime):当前显示的日期。
  • FirstDayOfWeek(DayOfWeek):一周的第一天。
  • TimeZone(TimeZoneInfo):显示预约所用的时区。
  • DaysViewSettings、TimelineViewSettings、MonthViewSettings:各视图设置。
  • ResourceCollection(ObservableCollection<SchedulerResource>):资源集合。
  • ResourceGroupType:分组类型(None、Resource、Date)。
  • AppointmentMapping:将自定义对象属性映射到预约属性。

视图专属设置:

  • DaysViewSettings:TimeInterval(时间槽间隔)、TimeIntervalSize(时间槽高度)、NonWorkingDays。
  • TimelineViewSettings:TimeInterval、TimeIntervalSize(时间线时间槽宽度)。
  • MonthViewSettings:NumberOfWeeksInView、ShowAgendaView。

常见模式

自定义预约绑定:

public class Meeting
{
    public string Title { get; set; }
    public DateTime From { get; set; }
    public DateTime To { get; set; }
    public bool AllDay { get; set; }
}
<scheduler:SfScheduler x:Name="Schedule"
                      ItemsSource="{Binding Meetings}">
    <scheduler:SfScheduler.AppointmentMapping>
        <scheduler:AppointmentMapping
            Subject="Title"
            StartTime="From"
            EndTime="To"
            IsAllDay="AllDay"/>
    </scheduler:SfScheduler.AppointmentMapping>
</scheduler:SfScheduler>

重复预约:

var recurringAppointment = new ScheduleAppointment
{
    StartTime = DateTime.Now.Date.AddHours(9),
    EndTime = DateTime.Now.Date.AddHours(10),
    Subject = "Daily Standup",
    RecurrenceRule = "FREQ=DAILY;INTERVAL=1;COUNT=10"
};

基于资源的排程:

var resources = new ObservableCollection<SchedulerResource>
{
    new SchedulerResource
    {
        Id = "1",
        Name = "Conference Room A",
        Background = new SolidColorBrush(Colors.Blue)
    },
    new SchedulerResource
    {
        Id = "2",
        Name = "Conference Room B",
        Background = new SolidColorBrush(Colors.Green)
    }
};

Schedule.ResourceCollection = resources;
Schedule.ResourceGroupType = ResourceGroupType.Resource;

var appointment = new ScheduleAppointment
{
    StartTime = DateTime.Now.Date.AddHours(10),
    EndTime = DateTime.Now.Date.AddHours(11),
    Subject = "Product Demo",
    ResourceIdCollection = new ObservableCollection<object> { "1" }
};

视图切换:

public void SwitchToMonthView()
{
    Schedule.ViewType = SchedulerViewType.Month;
}

public void SwitchToTimelineView()
{
    Schedule.ViewType = SchedulerViewType.TimelineWeek;
}

时区处理:

Schedule.TimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time");

var appointment = new ScheduleAppointment
{
    StartTime = new DateTime(2024, 3, 22, 10, 0, 0),
    EndTime = new DateTime(2024, 3, 22, 11, 0, 0),
    Subject = "Cross-timezone Meeting",
    StartTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Pacific Standard Time"),
    EndTimeZone = TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time")
};

适用场景

  • 会议室预订系统:基于资源的排程,显示会议室可用性并支持拖放预订。关键能力:资源分组、拖放、预约编辑。
  • 员工排班:跨多天显示员工班次,支持颜色编码。关键能力:资源分组、周/月视图、自定义预约颜色。
  • 医生预约系统:以时间槽和重复预约管理患者预约。关键能力:日/周视图、重复预约、预约编辑。
  • 事件日历:在月视图中显示事件及详情。关键能力:月视图、全天事件、自定义预约模板。
  • 项目时间线:在时间线视图中显示项目里程碑和任务。关键能力:时间线视图、跨天预约、资源分组。
  • 多时区排程:为全球团队处理不同时区的预约。关键能力:时区支持、时区转换、时间显示。

限制与暂未提供的信息

  • 收费、价格、授权方式:暂未提供。
  • 平台要求、系统版本等具体运行环境细节:暂未提供。
  • 与资料中未明确列出的功能、性能指标或效果:暂未提供。
  • 官方文档/参考资料中尚未体现的特殊定制能力:暂未提供。