Skip to content

SyncfusionExamples/How-to-set-alternate-row-styling-on-Xamarin.Forms-listview-based-on-span-count

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 

Repository files navigation

How to set alternate row styling on listview based on span count?

This example demonstrates how to define alternate row color for grid elements based on its span count in listview.

Sample

        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
                
            <syncfusion:SfListView x:Name="listView" SelectionMode="Multiple" 
                                   ItemSpacing="1" ItemSize="150"
                                   ItemsSource="{Binding contactsinfo}">
                <syncfusion:SfListView.LayoutManager>
                    <syncfusion:GridLayout x:Name="grid" SpanCount="4" />
                </syncfusion:SfListView.LayoutManager>
                <syncfusion:SfListView.ItemTemplate>
                    <DataTemplate>
                        <ViewCell>
                            <ViewCell.View>
                                <Grid x:Name="grid" RowSpacing="0"
                                      BackgroundColor="{Binding .,Converter={StaticResource IndexToColorConverter},ConverterParameter={x:Reference Name=listView}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="*" />
                                        <RowDefinition Height="1" />
                                    </Grid.RowDefinitions>
                                    <Grid RowSpacing="0">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="Auto" />
                                        </Grid.ColumnDefinitions>

                                        <Grid Grid.Column="1"
                          RowSpacing="1"
                          Padding="10,0,0,0"
                          VerticalOptions="Center">
                                            <Grid.RowDefinitions>
                                                <RowDefinition Height="*" />
                                                <RowDefinition Height="*" />
                                            </Grid.RowDefinitions>

                                            <Label LineBreakMode="NoWrap" Text="{Binding ContactName}"/>
                                            <Label Grid.Row="1" Grid.Column="0"
                             TextColor="#474747"
                             LineBreakMode="NoWrap"
                             Text="{Binding ContactNumber}">

                                            </Label>
                                        </Grid>
                                    </Grid>
                                </Grid>
                            </ViewCell.View>
                        </ViewCell>
                    </DataTemplate>
                </syncfusion:SfListView.ItemTemplate>
                
            </syncfusion:SfListView>
        </Grid>

See How to set alternate row styling on listview based on span count? for more details.

Requirements to run the demo

Troubleshooting

Path too long exception

If you are facing path too long exception when building this example project, close Visual Studio and rename the repository to short and build the project.

About

This example demonstrates how to define alternate row color for grid elements based on its span count in listview.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 6

Languages