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

Binding on RadListview not working

3 Answers 493 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Nisha
Top achievements
Rank 1
Nisha asked on 12 Mar 2018, 07:31 AM

Hi Team,

When I use normal Listview as shown below, the binding works:

<ListView x:Name="DetailsList"
                      HasUnevenRows="true"
                      ItemsSource="{Binding SavedDetailsList}"
                      SeparatorVisibility="None">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <local:BitDetailsInfoCell />
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>

=================Telerik RadListView Binding not working====================

But the same is not working when I am using Telerik RadListview.

<telerikDataControls:RadListView x:Name="DetailsList" Grid.Row="1"
                                    Grid.Column="0"
                                     BackgroundColor="White"
                                     IsItemSwipeEnabled="True"
                                     ItemsSource="{Binding SavedDetailsList}"
                                     SelectionMode="None"
                                     SwipeOffset="70, 0, 0, 0"
                                     SwipeThreshold="10">
        <telerikDataControls:RadListView.ItemTemplate>
            <DataTemplate>
                <telerikListView:ListViewTemplateCell>
                    <telerikListView:ListViewTemplateCell.View>
                        <Grid>
                            <Label Margin="10,10,10,0"
                                   FontAttributes="Bold"
                                   FontSize="16"
                                   Text="Nisha"
                                   TextColor="Black" />
                            <Label Grid.Row="1"
                                   Margin="10,0,10,10"
                                   FontAttributes="Italic"
                                   FontSize="13"
                                   Text="{Binding Path=Name,Converter={StaticResource NameConverter}}}"
                                   TextColor="Gray" />
                        </Grid>
                    </telerikListView:ListViewTemplateCell.View>
                </telerikListView:ListViewTemplateCell>
            </DataTemplate>
        </telerikDataControls:RadListView.ItemTemplate>
        <telerikDataControls:RadListView.ItemSwipeContentTemplate>
            <DataTemplate>
                <Grid Margin="0"
                      Padding="0"
                      ColumnSpacing="0"
                      RowSpacing="0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="70" />
                        <ColumnDefinition Width="*" />
                    </Grid.ColumnDefinitions>
                    <Button Margin="0"
                            BackgroundColor="Red"
                            BorderRadius="0"
                            Clicked="RemoveBook"
                            Image="delete_bg.png"
                            WidthRequest="70" />
                </Grid>
            </DataTemplate>
        </telerikDataControls:RadListView.ItemSwipeContentTemplate>
    </telerikDataControls:RadListView>

 

Please help me on this.

 

Regards,

Nisha

3 Answers, 1 is accepted

Sort by
0
Lance | Manager Technical Support
Telerik team
answered on 12 Mar 2018, 04:08 PM
Hi Nisha,

What you're experiencing is likely not related to the binding,but rather a missing dependencies or you have the control inside a StackLayout type of container (a container that squeezes the content to minimal space).

Here are two things you can try:

- Dependencies

Make sure you have all the required dependencies, go here to see the list.

- Parent container

Do not use the RadListView as child of a StackLayout or Grid RowDefinition with an Auto height. Instead use a Grid with a "*" height:

<ContentPage>
    <Grid>
        <telerikDataControls:RadListView />
    </Grid>
</ContentPage>


or give the RadListView an explicit height (e.g. HeightRequest="400")

<telerikDataControls:RadListView HeightRequest="400" />


Further Investigation

If neither of these work for you, then we need a way to reproduce the issue, the code below is unfortunately not enough information. Please open a support ticket here and attach a runnable reproducible (you can hard code example data if the data sourced is not accessible externally).


Quick note on your license

You are not current a Licensed User of UI for Xamarin, before you can open a support ticket, have your manager (or whoever purchased the UI for Xamarin license) assign you as a Licensed User by using the Manage Licensed Users portal here.

It is a very common scenario that the person/company whom purchases the license is not the developer. So when the owner assigns you as a Licensed User, they remain the owner and can change the Licensed User again at any time.

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
Joe
Top achievements
Rank 1
Veteran
answered on 19 Aug 2020, 02:51 PM
Thanks...I was having a problem I thought was related to refresh of the observable collection.  Actually was due to setting the row height to Height = "Auto" instead of Height="*"
0
Lance | Manager Technical Support
Telerik team
answered on 19 Aug 2020, 04:11 PM

Hello Joe,

I'm glad you were able to discover that on your own, it can be a frustrating thing to debug.  I wrote a documentation article on the topic that explains why this is even an issue, see Troubleshooting Controls Are Not Appearing.

Not Enough Room

In short, when you have a parent like StackLayout (or RowDefinition Height=Auto), the layout measure and arrange pass doesn't give enough room for the UI virtualized control. At runtime, the parent doesn't expand when the UI Virtualized control needs to render items, it doesn't know how much room to allocate (does it give for for 3-4 items, or all of the items?) There is no "outward pressure" to expand the parent.

When you use star-sized parent, the UI-virtualized control knows ahead of time that it will expand into the rest of the available space.

Infinite Height/Width

On the opposite side of things, like in a ScrollView, the UI-virtualized control expands into infinity. So it immediately renders all of the items into the ScrollViewer's panel (even though you don't see it). this nullifies the entire point of having UI virtualization in the first place, you might as well just do a for loop and add items manually to a StackLayout inside the ScrollView.

Mitigations

Unfortunately, it is outside of our control. We could go an set a minimum HeightRequest, but that would force everyone to meet that design requirement and breaks more than it fixes.

Personally, I wish Microsoft would stop using a StackLayout as the default child in a File > New Item > ContentPage. Replacing it with a Grid instead would save a lot of headaches.

Regards,
Lance | Manager - Technical Support
Progress Telerik

Tags
ListView
Asked by
Nisha
Top achievements
Rank 1
Answers by
Lance | Manager Technical Support
Telerik team
Joe
Top achievements
Rank 1
Veteran
Share this question
or