Hello guys,
I am facing issue with binding the contents to the RadListView.
I am doing it as follows,
<telerikDataControls:RadListView Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" x:Name="uiListView" ItemsSource="{Binding Assets}">
<!--'Assets' is the list of asset.-->
<telerikDataControls:RadListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.View>
<StackLayout>
<Grid Padding="10,10,10,0">
<Label Grid.Row="0" Grid.Column="0" Text="{Binding AssetNumber}" FontSize="14" FontAttributes="Bold" LineBreakMode="NoWrap"/>
</Grid>
</StackLayout>
</ViewCell.View>
</ViewCell>
</DataTemplate>
</telerikDataControls:RadListView.ItemTemplate>
<telerikDataControls:RadListView.SelectedItemStyle>
<telerikListView:ListViewItemStyle BackgroundColor="#88888888"/>
</telerikDataControls:RadListView.SelectedItemStyle>
</telerikDataControls:RadListView>
6 Answers, 1 is accepted
If you want to have a custom cell, you need to use the ListViewTemplateCell, find the documentation here.
Here is your DataTemplate, updated for use with the RadListView:
<
telerikDataControls:RadListView.ItemTemplate
>
<
DataTemplate
>
<
listView:ListViewTemplateCell
>
<
listView:ListViewTemplateCell.View
>
<
Grid
Padding
=
"10,10,10,0"
>
<
Label
Grid.Row
=
"0"
Grid.Column
=
"0"
Text
=
"{Binding AssetNumber}"
FontSize
=
"14"
FontAttributes
=
"Bold"
LineBreakMode
=
"NoWrap"
/>
</
Grid
>
</
listView:ListViewTemplateCell.View
>
</
listView:ListViewTemplateCell
>
</
DataTemplate
>
</
telerikDataControls:RadListView.ItemTemplate
>
Seeing your template, I recommend trying the ListViewTextCell as it provides both a main Text and Detail text binding option with well formatted styling out-of-the-box.
Lastly, I see that you're adding some padding for the item, you can also use the VerticalItemSpacing feature of the RadListView to get the desired amount of spacing between items. See here for example code and screenshots.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
You're already doing it with the SelectedItemStyle, please take a look at this page in the documentation for further guidance op Selection and here for selected item styling..
This also depends on the platform specific UI guidance. If you run the app on iOS, you will see checkboxes for the selected items when in multiple selection mode, this is the expected UI guidance for iOS.
If you need to have a custom setup and have checkboxes on every platform, then you'll need to do two things:
- Add an "IsSelected" property to the model
- Add a checkbox to the item template, bound to the IsSelected property
- Toggle the IsSelected value in the selection changed event.
Is there a relationship between that button you've added to the ItemTemplate and the IsSelected? If you are making the selection using that button, you can easily toggle the IsSelected value there as well.
Regards,
Lance | Tech Support Engineer, Sr.
Telerik by Progress
Is it possible to databind to the SelectedItems property of RadListView in case of edit a form. I want to display an item as selected when the RadListView load.
Please let me know your reply on this.
Thanks,
Currently, Selected items are not bindable properties. As a result you can bind it to your viewmodel only through attached property or behavior by passing the selected property instance and assigning it to your viewmodel property (Simulation one way to source binding).
This is a requested feature and it is logged in our feedback portal You can track its progress and vote for it.
Regards,
Tsvyatko
Telerik by Progress