Sflistview with DynamicHeight isnt adapting to content.

Im currently using Xamarin forms sfListView. When the content inside a Row change ( also using propertychanged) the Height is not adapting.
In the image atached we can see in the first row the text change during the excecution, and the height dont change. Also the second row is loaded on init and the height doesnt adapt either.
I tried a lot of solution with no success. Only using a stacklayout insted a grid the problem disapear. But i really need a listview with a grid inside with adaptatives rows.
How can i fix it?
Regards

sfListView version : 19.3.0.54
 Xamarin.Forms verion 5.0.0.224

<listView:SfListView
        x:Name="productsList"
        ItemsSource="{Binding saleNoteItems}"
        IsVisible="{Binding cartListVisible}"
        IsScrollingEnabled="false"
        ItemSpacing="10,5"
        VerticalOptions="CenterAndExpand"
        SelectionMode="Single"
        SelectionBackgroundColor="Transparent"
        BackgroundColor="{StaticResource Gray-100}"
        AutoFitMode="DynamicHeight">
    <listView:SfListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <ViewCell.View>
                    <StackLayout Grid.Column="0" Margin="0">
                        <Grid
                            ColumnSpacing="0"
                            Grid.ColumnDefinitions="0.60*,0.1*, 0.15*, 0.15*"
                            Grid.RowDefinitions="auto, auto"
                            RowSpacing="0"
                            Padding="10">
                            <Label
                                Grid.Row="0"
                                Grid.Column="0"
                                FontFamily="Montserrat-Medium"
                                FontSize="12"
                                Text="{Binding Description}"
                                TextColor="{DynamicResource Gray-800}"
                                LineBreakMode="WordWrap"
                                VerticalOptions="CenterAndExpand"
                                HorizontalOptions="StartAndExpand"/>
                            <Label
                                Grid.Row="1"
                                Grid.Column="0"
                                FontFamily="Montserrat-Medium"
                                FontSize="10"
                                Text="{Binding Total, StringFormat='{0:C}'}"
                                TextColor="{DynamicResource Gray-800}"
                                VerticalOptions="EndAndExpand"
                                HorizontalOptions="StartAndExpand"/>
                            <Label
                                Grid.Row="0" Grid.RowSpan="2"
                                Grid.Column="1"
                                FontFamily="Montserrat-Medium"
                                FontSize="Small"
                                Text="{Binding Quantity}"
                                TextColor="{DynamicResource Gray-800}"
                                VerticalOptions="CenterAndExpand"/>
                            <buttons:SfButton
                                Grid.Row="0" Grid.RowSpan="2"
                                Grid.Column="2"
                                IsEnabled="{Binding IsButtonEnabled}"
                                IsVisible="{Binding IsProduct}"
                                Command="{Binding Path=BindingContext.PlusItemCommand, Source={x:Reference productsList}}"
                                CommandParameter="{Binding .}"
                                ShowIcon="True"
                                ImageSource="{StaticResource Icon_Plus_Circle}"
                                ImageWidth="45"
                                BackgroundColor="Transparent"
                                HorizontalOptions="CenterAndExpand"
                                VerticalOptions="CenterAndExpand">
                            </buttons:SfButton>
                            <buttons:SfButton
                                Grid.Row="0" Grid.RowSpan="2"
                                Grid.Column="3"
                                IsEnabled="{Binding IsButtonEnabled}"
                                Command="{Binding Path=BindingContext.MinusKitCommand, Source={x:Reference productsList}}"
                                CommandParameter="{Binding .}"
                                ShowIcon="True"
                                ImageSource="{StaticResource Icon_Minus_Circle}"
                                ImageWidth="45"
                                BackgroundColor="Transparent"
                                HorizontalOptions="CenterAndExpand"
                                VerticalOptions="CenterAndExpand">
                            </buttons:SfButton>
                        </Grid>
                    </StackLayout>
                </ViewCell.View>
            </ViewCell>
        </DataTemplate>
    </listView:SfListView.ItemTemplate>
</listView:SfListView>



3 Replies

LN Lakshmi Natarajan Syncfusion Team June 20, 2022 01:36 PM UTC

Hi Nelson,


We have modified the code snippets given to achieve your requirement using Grid. Please refer to the following code snippets and output for more reference,


<listView:SfListView

x:Name="productsList"

ItemsSource="{Binding ContactsInfo}"

IsScrollingEnabled="False"

ItemSpacing="10,5"

VerticalOptions="CenterAndExpand"

SelectionMode="Single"

SelectionBackgroundColor="Transparent"

AutoFitMode="DynamicHeight">

    <listView:SfListView.ItemTemplate>

        <DataTemplate>

            <ViewCell>

                <ViewCell.View>

                    <Frame BorderColor="LightGray" Padding="10" CornerRadius="10">

                        <Grid

                ColumnSpacing="0"

                ColumnDefinitions="0.60*,0.10*, 0.30*"

                RowSpacing="0">

                            <Grid RowDefinitions="Auto, Auto">

                                <Label

                    Grid.Row="0"

                    Grid.Column="0"

                    FontSize="12"

                    Text="{Binding Description}"

                    LineBreakMode="WordWrap"

                    VerticalOptions="CenterAndExpand"

                    HorizontalOptions="StartAndExpand"/>

                                <Label

                    Grid.Row="1"

                    Grid.Column="0"

                    FontSize="10"

                    Text="{Binding Total, StringFormat='{0:C}'}"

                    VerticalOptions="EndAndExpand"

                    HorizontalOptions="StartAndExpand"/>

                            </Grid>

                            <Label

                    Grid.Row="0"

                    Grid.Column="1"

                    FontSize="Small"

                    Text="{Binding Quantity}"

                    VerticalOptions="CenterAndExpand"/>

                            <Grid Grid.Column="2">

                                <buttons:SfButton

                    ShowIcon="True"

                    ImageSource="plus"

                    ImageWidth="45"

                    BackgroundColor="Transparent"

                    HorizontalOptions="CenterAndExpand"

                    VerticalOptions="CenterAndExpand">

                                </buttons:SfButton>

                                <buttons:SfButton

                    ShowIcon="True" Grid.Column="1"

                    ImageSource="minus"

                    ImageWidth="45"

                    BackgroundColor="Transparent"

                    HorizontalOptions="CenterAndExpand"

                    VerticalOptions="CenterAndExpand">

                                </buttons:SfButton>

                            </Grid>

                        </Grid>

                    </Frame>

                </ViewCell.View>

            </ViewCell>

        </DataTemplate>

    </listView:SfListView.ItemTemplate>

</listView:SfListView>


Output


Please let us know if you need further assistance.


Regards,

Lakshmi Natarajan



NE Nelson June 20, 2022 11:36 PM UTC

Thanks for your reply. Its works perfectly


Regards



LN Lakshmi Natarajan Syncfusion Team June 21, 2022 05:03 AM UTC

Hi Nelson,


If you are satisfied with our response, please mark it as an answer. Otherwise, please let us know if you have any further queries on this. We are happy to help you.


Regards,

Lakshmi Natarajan



Loader.
Up arrow icon