We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to autofit the content based on the property change in xamarin.forms listview using MVVM ?

Platform: Xamarin.Forms |
Control: SfListView |
Published Date: November 26, 2018 |
Last Revised Date: November 26, 2018
Tags: autofit

You can autofit the listview item when loading ItemTemplate through ItemTemplateSelector based on the property value changed at runtime. This can be done by using the RefreshListViewItem method.

Refer to the following code for loading listveiwitem with ItemTemplate based on the property value.

 

Refer to the following code for changing property value in ViewModel.

 

Here, refreshing the listview item in the PropertyChanged event when changing the property value from ViewModel.

 

Output:

Template1 as ItemTemplate when loading listview item.

Template1 as the ItemTemplate

Template2 as ItemTemplate when clicking Show More button which auto fit the content.

Template2 as the ItemTemplate

Click here to download the sample.

 

2X faster development

The ultimate Xamarin UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile