As explained in Crosslight and MVVM at a Glance, it shows code example that derives from ListViewModelBase(T) Class which serves as the base class for all ViewModel that present a list of data. In fact, Crosslight ships with numerous ViewModel base classes that you can choose to quickly getting started with cross-platform mobile development.
Each ViewModel base class in Crosslight is modeled based on typical business mobile apps and is designed to accomplish an obvious objective. See the following list for the pre-built ViewModel base classes available in Crosslight Foundation.
Get started with this base class if your view isn’t specifically categorized, or you’re not sure which ViewModel is suitable for the view. You may easily change to other base classes later to better match the objective of the view. All ViewModel base classes in the following are derived from this base class which contains many pre-built functionality such as access to presenters and mobile services.
Choose this base class to provide a list of items to be presented in your view. This base class supports many data-related features such as grouping and filtering, as well as selection-related features like selected item and selected items management.
- EditableListViewModelBase(T) Class
Similar to ListViewModelBase, this base class is used to provide a list of items. In addition, you should consider inheriting from this base class when the items list are editable, for instances, users are allowed to add new items, or delete items from the list. This base class includes several predefined commands that you can consume directly such as AddCommand, EditCommand, DeleteCommand, ReorderCommand and more.
- GroupListViewModelBase(TGroup, TItem) Class
Choose this base class to provide grouped items that represents a group and the items contained in the particular group.
- MultiPageViewModelBase Class
Choose this base class to provide the navigation items for multi-page view source such as tab bar. With this class, you can maintain the selected index of the multi-page view from within the ViewModel which makes it easy to interact with other shareable user interaction logic code.
- DetailViewModelBase(T) Class
Choose this base class to provide simple, read-only details for an object. This class contains a generic property that represents the object which will be used as the binding source.
- EditableDetailViewModelBase(T) Class
Similar to DetailViewModelBase in purpose, but this base class provides convenient pre-built editing features such as EditCommand and DeleteCommand.
- EditorViewModelBase(T) Class
Choose this base class to provide editable detail for an object. This base class contains many convenient editing management such as data validation and error management, commands for save and cancel, determines whether data is dirty, and much more.
The usage of the base classes above will be further explained according to the relevant guides in Crosslight documentation.