This is a migrated thread and some comments may be shown as answers.

Minimum row height

2 Answers 543 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Ian
Top achievements
Rank 1
Ian asked on 17 Sep 2018, 09:02 PM
Is it possible to have rows size dynamically based on their content and to set a minimum height?

2 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 17 Sep 2018, 09:43 PM
Hi Ian,

Currently there isn't a property available in the Telerik API or RadListView API (i.e. ListViewLayoutDefinition) that sets a minimum height, yet still allows for expansion. I've submitted a Feature Request: ListView: LayoutDefinition MinimumItemLength property

Unnecessary Feature

You don't need to wait for such a feature to be implemented, because the minimum height is the amount determined by your custom content.

For example, here's a demo where there are three Labels. One of the labels is hidden or shown depending on a boolean value.

<listView:ListViewTemplateCell>
    <StackLayout>
         <Label Text="{Binding Title}" />
         <Label Text="{Binding Author}" />
         <Label Text="Is Favorite!"
              IsVisible="{Binding IsFavorite}" />
    </StackLayout>
</listView:ListViewTemplateCell>


The cells always take up the minimum amount of space defined by the template.



This means your custom content can determine the minimum height and you don't need an API from the RadListView to achieve the goal. You'll just need to consider what needs to be the minimum height for your content and set it accordingly.

For example, here's the same code from above, but I've stated that I don't want the two labels to be smaller than 200px:

<listView:ListViewTemplateCell>
    <StackLayout>
        <StackLayout HeightRequest="200">
            <Label Text="{Binding Title}" />
            <Label Text="{Binding Author}" />
        </StackLayout>
        <Label Text="Is Favorite!"
               IsVisible="{Binding IsFavorite}" />
    </StackLayout>
</listView:ListViewTemplateCell>


Here's the result at runtime, you can clearly see that the IsFavorite cell is larger than the other cells that have a minimum of 200px:




I hope this clarifies the case. I've still submitted the feature request because I think it will be useful for edge cases where you can't change the height values of the content.

Regards,
Lance | Tech Support Engineer, Sr.
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Ian
Top achievements
Rank 1
answered on 18 Sep 2018, 11:08 AM
This strategy works. I thought I'd already tried it but I must have made a mistake.
Tags
ListView
Asked by
Ian
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Ian
Top achievements
Rank 1
Share this question
or