[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
   Reporting
  [Expand]Data Grid
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Gantt Control
  [Expand]Diagram Control
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
  [Collapse]Scheduler (legacy)
   [Expand]Overview
   [Expand]Getting Started
   [Expand]Fundamentals
   [Expand]Visual Elements
   [Collapse]Examples
    [Expand]Appearance
    [Collapse]Data Binding
      How to: Bind a Scheduler to MS Access Database (Part 1) (legacy)
      How to: Bind a Scheduler to MS Access Database (Part 2) (legacy)
      How to: Bind a Scheduler to Data via ObjectDataProvider (legacy)
      How to: Create a Custom Field for an Appointment (legacy)
      How to: Filter Appointments (legacy)
      How to: Filter Resources (legacy)
    [Expand]Data Exchange
    [Expand]Date and Time
    [Expand]Forms
    [Expand]Initial Settings
    [Expand]Menu
    [Expand]Printing
    [Expand]Protection
    [Expand]Range Control
    [Expand]Recurrence
    [Expand]Selection
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

How to: Bind a Scheduler to Data via ObjectDataProvider (legacy)

Note

You are viewing documentation for the legacy WPF Scheduler control. If you're starting a new project, we strongly recommend that you use a new control declared in the DevExpress.Xpf.Scheduling namespace. If you decide to upgrade an existing project in order to switch to the updated scheduler control, see the Migration Guidelines document.

This document demonstrates how to bind a Scheduler Control to a collection of custom objects that implement the System.ComponentModel.IBindingList interface, although the scheduler control can be bound to a variety of other data sources. In this tutorial, we will use the System.Windows.Data.ObjectDataProvider object to bind Scheduler Storage to the data source directly in the XAML markup.

Expanded Step 1. Create Appointment Object Class

  1. Create a new WPF Application project in Visual Studio 2010.
  2. Add the SchedulerControl object to your project.
  3. Create a new class item in Visual Studio. Call it CustomEvent.
  4. Define a CustomEvent class, which will contain all the necessary properties for an appointment in the AppointmentStorage collection: start, end (beginning and ending scheduled times), subject, description, location, status (specifying the appointment status), eventType (specifying the appointment's recurrence type), label (specifying the appointment label), allday, recurrenceinfo, reminderinfo. This set of properties will be used in default mappings to uniform the number and types of parameters used when data is transported from the datasource to the scheduler storage and vice versa.

Expanded Step 2. Create Data Source Object

  1. Create the CustomEventProvider class to be a data source to be bound to the scheduler control.
  2. Define the following methods.

    • The CreateEvent method will create the CustomEvent class instance to represent a particular appointment in the data source. Time interval for each appointment will be specified randomly.
    • The GetCustomEvents method will return the CustomEvent object collection. This method will call the CreateEvent method, then generate a subject, status and label for each created appointment, and add the CustomEvent object to the collection. This collection will be used as a datasource for the scheduler control. Proceed to the next step to learn how to bind scheduler storage to this method via System.Windows.Data.ObjectDataProvider.

      Note

      In this example, each appointment subject is formed from an element of the Users array and one of the prefixes: meeting, travel or phone call.

Expanded Step 3. Use ObjectDataProvider for Binding to Data

Provide the AppointmentStorage with data returned by the CustomEventProvider.GetCustomEvents method. To do this, use System.Windows.Data.ObjectDataProvider in XAML.

  1. Add the WpfApplication1 namespace and set the local prefix for it to provide the capability to refer to the CustomEventProvider class.
  2. Create the ObjectDataProvider object.
  3. Set the ObjectDataProvider.ObjectType property to CustomEventProvider to specify the data source object type.
  4. Set the ObjectDataProvider.MethodName property to GetCustomEvents to call the CustomEventProvider.GetCustomEvents method and bind the AppointmentStorage to its results.

Expanded Step 4. Specify Mappings

Specify mappings of the appointment standard properties to appropriate properties of the CustomEvent object. To do this, use the AppointmentMapping object accessed via the AppointmentStorage.Mappings property.

Expanded Result

Run the project. The following image shows the resulting scheduler control at runtime.

Expanded See Also

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E3187.

Is this topic helpful?​​​​​​​