Hello Nidhi,
Here's an example you can use to verify my last reply.
Runtime Screenshot (notice variable cell height depending on value of IsFavorite)
:
XAML
xmlns:local
=
"clr-namespace:NidhiDynamicCellHeightDemo.Portable"
xmlns:dataControls
=
"clr-namespace:Telerik.XamarinForms.DataControls;assembly=Telerik.XamarinForms.DataControls"
xmlns:listView
=
"clr-namespace:Telerik.XamarinForms.DataControls.ListView;assembly=Telerik.XamarinForms.DataControls"
xmlns:primitives
=
"clr-namespace:Telerik.XamarinForms.Primitives;assembly=Telerik.XamarinForms.Primitives"
x:Class
=
"NidhiDynamicCellHeightDemo.Portable.MainPage"
>
<
ContentPage.BindingContext
>
<
local:ViewModel
/>
</
ContentPage.BindingContext
>
<
Grid
>
<
dataControls:RadListView
x:Name
=
"listView"
ItemsSource
=
"{Binding Source}"
>
<
dataControls:RadListView.ItemTemplate
>
<
DataTemplate
>
<
listView:ListViewTemplateCell
>
<
primitives:RadBorder
BorderColor
=
"DarkSlateBlue"
BorderThickness
=
"2"
BackgroundColor
=
"Lavender"
>
<
StackLayout
Margin
=
"10,5,10,5"
>
<
Label
Text
=
"{Binding Title}"
FontSize
=
"16"
FontAttributes
=
"Bold"
TextColor
=
"Black"
VerticalOptions
=
"Center"
/>
<
Label
Text
=
"{Binding Author, StringFormat='by {0}'}"
FontAttributes
=
"Italic"
/>
<!-- This will be visible for some items, making the cell larger than the others. -->
<
primitives:RadBorder
IsVisible
=
"{Binding IsFavorite}"
BackgroundColor
=
"DarkSlateBlue"
Padding
=
"5"
HorizontalOptions
=
"Fill"
>
<
Label
Text
=
"favorite"
TextColor
=
"White"
HorizontalTextAlignment
=
"Center"
VerticalTextAlignment
=
"Center"
/>
</
primitives:RadBorder
>
</
StackLayout
>
</
primitives:RadBorder
>
</
listView:ListViewTemplateCell
>
</
DataTemplate
>
</
dataControls:RadListView.ItemTemplate
>
</
dataControls:RadListView
>
</
Grid
>
</
ContentPage
>
C#
using
System.Collections.ObjectModel;
using
Xamarin.Forms;
namespace
NidhiDynamicCellHeightDemo.Portable
{
public
partial
class
MainPage : ContentPage
{
public
MainPage()
{
InitializeComponent();
}
}
public
class
Book
{
public
string
Title {
get
;
set
; }
public
string
Author {
get
;
set
; }
public
bool
IsFavorite {
get
;
set
; }
}
public
class
ViewModel
{
public
ObservableCollection<Book> Source {
get
;
set
; } =
new
ObservableCollection<Book>{
new
Book{ Title =
"The Fault in Our Stars "
, Author =
"John Green"
},
new
Book{ Title =
"Divergent"
, Author =
"Veronica Roth"
, IsFavorite =
true
},
new
Book{ Title =
"Gone Girl"
, Author =
"Gillian Flynn"
, IsFavorite =
true
},
new
Book{ Title =
"Clockwork Angel"
, Author =
"Cassandra Clare"
},
new
Book{ Title =
"The Martian"
, Author =
"Andy Weir"
, IsFavorite =
true
},
new
Book{ Title =
"Ready Player One"
, Author =
"Ernest Cline"
},
new
Book{ Title =
"The Lost Hero"
, Author =
"Rick Riordan"
, IsFavorite =
true
},
new
Book{ Title =
"All the Light We Cannot See"
, Author =
"Anthony Doerr"
},
new
Book{ Title =
"Cinder"
, Author =
"Marissa Meyer"
},
new
Book{ Title =
"Me Before You"
, Author =
"Jojo Moyes"
},
new
Book{ Title =
"The Night Circus"
, Author =
"Erin Morgenstern"
},
};
}
}
As I mentioned before, if you have trouble please open a ticket or start a new thread (the original question Roshan asked was how to set an explicit height).
Regards,
Lance | Technical Support Engineer, Principal
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