This example demonstrates how to specify custom native Android and iOS views for date headers and cells of the Day View. To do this, implement view providers and register these implementations in each platform project.
To run the application:
- Obtain your NuGet feed URL.
- Register the DevExpress NuGet feed as a package source.
- Restore all NuGet packages for the solution.
-
Create the CustomDateHeaderViewProvider.cs and CustomDayCellViewProvider.cs classes that define custom view providers for date headers and cells. A view provider class should implement the IViewProvider or ICachedViewProvider (for views with many elements) interface.
- CustomDateHeaderViewProvider - implements the IViewProvider interface.
The CreateNewView method creates a View object, and the BindView method binds this view to data. - CustomDayCellViewProvider - implements the ICachedViewProvider interface.
This class contains methods that reduce a view's creation and load time:- RequestViewFromCache - before creating a view, checks whether the cache already contains it. If it does, it loads the existing view. If a view cannot be returned from the cache, the CreateNewView method creates a new view (an instance of the CustomCell.cs class that inherits View).
- RecycleView - adds a view to the cache.
- Recycle - clears the cache.
- CustomDateHeaderViewProvider - implements the IViewProvider interface.
-
In the MainActivity.cs file, register a custom service that inherits the DayViewProviderService class and override the CreateCellViewProvider and CreateDateHeaderViewProvider methods to use custom view providers for cells and date headers.
-
Create the CustomDateHeaderViewProvider.cs and CustomCellViewProvider.cs classes that implement the IViewProvider interface and define custom view providers for date headers and cells.
- CustomDateHeaderViewProvider
The RequestView method returns a new view (an instance of the CustomDateHeader.cs class that inherits UIView), and the BindView method binds this view to data. - CustomDayCellViewProvider
This class has the following methods:- RequestView - returns a view from the cache, if any, otherwise creates a new view (an instance of the CustomCell.cs class that inherits UIView).
- RecycleView - adds a view to the cache.
- CustomDateHeaderViewProvider
-
In the AppDelegate.cs file, register a custom service that inherits the DayViewProviderService class and override the CreateCellViewProvider and CreateDateHeaderViewProvider methods to use custom view providers for cells and date headers.
Note that the DayViewProviderService class has also methods that allow you to specify custom view providers for other Day View elements:
- CreateAppointmentViewProvider
- CreateAllDayAppointmentViewProvider
- CreateAllDayCellViewProvider
- CreateTimeRulerCellViewProvider
- CreateTimeRulerHeaderViewProvider