Skip to main content

DXCollectionView.ItemSpanCount Property

Gets or sets the number of layout columns or rows (depending on Orientation) that are used to arrange CollectionView items. This is a bindable property.

Namespace: DevExpress.Maui.CollectionView

Assembly: DevExpress.Maui.CollectionView.dll

NuGet Package: DevExpress.Maui.CollectionView

Declaration

public int ItemSpanCount { get; set; }

Property Value

Type Description
Int32

The number of layout spans in DXCollectionView.

Remarks

The following schema shows how the DXCollectionView control positions items in multi-span mode for different DXCollectionView.Orientation values:

DevExpress CollectionView for .NET MAUI - Item order in multi-span

Limitations

The following functionality is not supported for DXCollectionView instances with ItemSpanCount set to a value greater than 1:

Example

The following example specifies the ItemSpanCount property value depending on screen orientation. The example positions two CollectionView items per row for Portrait device orientation and three items for Landscape orientation:

DevExpress CollectionView for .NET MAUI

<dxcv:DXCollectionView x:Name="collectionView"
               Orientation="Vertical"
               ItemsSource="{Binding ItemsSource}"
               ItemTemplate="{StaticResource houseCardTemplate}"...>
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroupList>
            <VisualStateGroup>
                <VisualState x:Name="Portrait">
                    <VisualState.StateTriggers>
                        <OrientationStateTrigger Orientation="Portrait" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Property="ItemSpanCount" Value="2" />
                    </VisualState.Setters>
                </VisualState>
                <VisualState x:Name="Landscape">
                    <VisualState.StateTriggers>
                        <OrientationStateTrigger Orientation="Landscape" />
                    </VisualState.StateTriggers>
                    <VisualState.Setters>
                        <Setter Property="ItemSpanCount" Value="3" />
                    </VisualState.Setters>
                </VisualState>
            </VisualStateGroup>
        </VisualStateGroupList>
    </VisualStateManager.VisualStateGroups>
</dxcv:DXCollectionView>
See Also