Choosing Templates Based on Custom Logic
Columns and Views provide multiple properties that allow you to define templates and change the visual presentation of their elements (cells, rows, summary items, etc.). A template is applied to multiple elements in the same scope. If however, you have more than one template that can be applied to a target element (e.g. a cell, row), you can implement custom logic to choose the required template. This allows you to provide a different visual appearance for individual grid elements.
For example, a template that defines the presentation of data cells is specified by the DataViewBase.CellTemplate property. If you want to conditionally apply templates to them:
- Create a template selector - a class that chooses a template if the required condition is met. This class must derive from the DataTemplateSelector class and override the SelectTemplate method, to return a template that meets the required condition.
- Assign its instance to the DataViewBase.CellTemplateSelector property.
#Example: Applying Templates Based on Custom Logic
See Also