Implementing View-ViewModel
The purpose of this tutorial is to show you how to bind a RadScheduler with a ViewModel.
Before reading this tutorial you should get familiar with the Data Binding support of the RadScheduler control.
- Add a new RadScheduler declaration in your XAML
Example 1
- Create a new class named MyViewModel.
Example 2
-
In the MyViewModel class add two properties:
- Appointments: We will bind the AppointmentsSource property of the RadScheduler to this property.
- ResourcesTypes: We will bind the ResourceTypesSource property of the RadScheduler to this property.
Example 3
- Let's create a method in the ViewModel that generates some Resources:
Example 4
- All we have to do is to initialize the resourceTypes and appointments fields:
Example 5
- The ViewModel is complete. Now, let's return to the View. Add some ViewDefinitions, GroupDescriptionsSource and bind the AppointmentsSource and ResourceTypes
Example 6
- Finally, set the DataContext: