ItemTemplate/DataTemplate warnings

Controls used to display collections, including ListView, CollectionView, and BindableLayout, require defining an ItemTemplate with certain requirements. The warnings on this page are focused on the current definition of ItemTemplate with an appropriate DataTemplate.

[XR5035, XR5069, XR5072] ItemTemplate requires single child DataTemplate child

The <control.ItemTemplate> element must have a single child, and it must be a DataTemplate.

[XR5036, XR5066, XR5067, XR5068, XR5071, XR5073] ItemTemplate declaration errors

With Xamarin.Forms, the child of a DataTemplate within a <control.ItemTemplate> has some constraints depending on context. For ListView.ItemTemplate, the child must be Cell type, or derive from Cell. One the other hand, most other uses of DataTemplate require that the child does not derive from Cell. These warnings flag various situations in which the child of a DataTemplate is either a Cell (when it shouldn’t be), or isn’t a Cell (when it must be).

[XR5038, XR5039] GroupHeader declaration errors

Creating grouped lists on Xamarin.Forms involves multiple settings on ListView. The GroupHeaderTemplate or GroupDisplayBinding properties on a ListView are used to specify the layout used for the GroupHeader of a ListView and as their names imply are only relevant if the ListView is grouped. These warnings perform validation on these settings.

If GroupHeaderTemplate or GroupDisplayBinding is declared, a warning is generated if the IsGroupingEnabled property is not set to true. Setting both GroupHeaderTemplate and GroupDisplayBinding can also be problematic as the GroupDisplayBinding when set will use the default template as the layout for the GroupHeader. Hence, one of the declarations will be ignored. XamRight warns if it detects the declaration of both these properties.

Author