Implementing View-ViewModel
The purpose of this tutorial is to show you how to bind a RadGanttView with a ViewModel.
Before reading this tutorial you should get familiar with the Data Binding support of the RadGanttView control.
- Add a new RadGanttView declaration in your XAML:
- Create a new class named MyViewModel:
- In the MyViewModel class add Tasks property. We will bind the TasksSource property of the RadGanttView to this property.
- All we have to do is to initialize the tasks field:
- The ViewModel is complete. Now, let's return to the View. Add TasksSource property to the definition of the GanttView:
- Finally, set the DataContext:
And the result is: