This walkthrough provides step-by-step instructions to bind UXScheduleView to DevForce Services and displaying a collection of data using MVVM pattern.
You need the following components to complete this walkthrough:
- Visual Studio 2010 SP1
- IdeaBlade DevForce 6.0.9 or later
- Silverlight 4 Tools for Visual Studio 2010
- Intersoft ClientUI 5 or later
Creating a new ClientUI MVVM Schedule Application (DevForce) Project
The first step is to create a new ClientUI MVVM Schedule Application (DevForce) project using Intersoft ClientUI MVVM Schedule Application (DevForce) project template in Visual Studio.
To create the ClientUI MVVM Schedule Application (DevForce) project
- Start Visual Studio 2010.
- Create a new ClientUI MVVM Schedule Application (DevForce) project using Intersoft ClientUI MVVM Schedule Application (DevForce) project template. To learn more, see Walkthrough: Create New Intersoft ClientUI MVVM Schedule Application (DevForce) Template.
Creating Model Repository Class
This section shows how to create the SoftwareDevEventsRepository class, SoftwareDevCategoriesRepository class and SoftwareDevResourcesRepository class that represents the required data repositories used in this walkthrough.
To Create the SoftwareDevEventsRepository Class
- Create a new data repository for SoftwareDevEvents using Intersoft MVVM Data Repository (DevForce) item template under the ModelServices folder. You can name it SoftwareDevEventsRepository .cs
- Replace the default base class in the DataRepository and remove the Validate method. If you would like to create a repository that supports editing, choose the EditableDataRepository as the base class instead of the DataRepository.
- Replace all the <T> placeholders with the target entity type such as SoftwareDevEvent.
- Replace the type of the EntityContext property to the default domain context type such as ScheduleViewSampleDataDomainContext.
To Create the SoftwareDevCategoriesRepository and SoftwareDevResourcesRepository Class
- Repeat the steps when creating the SoftwareDevEventsRepository class.
- Replace all the <T> placeholders with the target entity type such as SoftwareDevCategory and SoftwareDevResource.
Creating The View
This section steps you through the process of adding a new calendar page to display a collection of software dev data.
- Add new UXPage in View folder and name it CalendarDev.xaml.
Add UXScheduleView directly under layout root.
Creating the ViewModel
This section steps you through the process of creating a ViewModel class that contains the properties to describe the View that you created in the previous section. The ViewModel will inherit the ScheduleViewModelBase class which already contains a set of common properties that will be used in UXScheduleView such as Events. You can also choose to inherit from EditableScheduleViewModelGenericBase to create a ViewModel that supports data editing features such as add, edit and delete.
To create the SoftwareDevCalendarViewModel
- Add a new class to the ViewModels folder in your Silverlight project and name it SoftwareDevCalendarViewModel.
- Open SoftwareDevCalendarViewModel.cs and inherit the class from ScheduleViewModelBase class, then replace the placeholders with the target entity type, i.e., <SoftwareDevEvent>. The ScheduleViewModelBase class contains common members that can be bound to the UXScheduleView control.
Binding the View to the ViewModel
In the previous sections, you have learned how to create the Model and ViewModel classes, as well as the View that contains the user interface and controls used in this walkthrough. This section shows how to instantiate the ViewModel in the XAML page and bind the UI elements to the properties in the ViewModel such as the data context and UXScheduleView EventsSource property.
To bind the CalendarDev page to the CalendarDevViewModel class
Declare the namespace that maps to the CalendarDevViewModel class in the Customers page.
Instantiate a new instance of the CalendarDevViewModel class in the UXPage resources and name it CalendarDevViewModel.
In UXScheduleView control bind the EventsSource, CategoriesSource and ResourcesSource properties with properties in the SoftwareDevViewModel.
Adding the CalendarDev page to the navigation pane.
- Open the MainPage.xaml.
Add new navigation pane item below the existing calendar item and specify the NavigateUri to CalendarDev.
- Save and run the project.
In this walkthrough, you have learned how to create ClientUI MVVM Schedule Application (DevForce) project using project template, and create the classes and page based on the Model, View and ViewModel pattern. You also learned how to bind UXScheduleView to a collection of data.
Complete Code Listing
This section lists the complete code used in this walkthrough.