How to bind to a list or a observationCollection to a custom view?

mc 4,111 Reputation points

I created a custom view and want to bind a property which is list or observationCollection.

when I add items to the list in viewModel the list in custom view will be changed to .

how to do it?

It seems that it can not use bindableProperty

A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,325 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Cole Xia (Shanghai Wicresoft Co,.Ltd.) 6,751 Reputation points


    Welcome to Microsoft Q&A!

    Firstly take a look at Bindable Layouts in Xamarin.Forms .

    Bindable layouts enable any layout class that derives from the Layout<T> class to generate its content by binding to a collection of items .

    BindableLayout exposes the attached properties (including ItemsSource ,ItemTemplate) .

    The usage is pretty simple

       <StackLayout BindableLayout.ItemsSource="{Binding User.TopFollowers}"  
                   <controls:CircleImage Source="{Binding}"  
                                         ... />  

    Note : While it's technically possible to attach a bindable layout to any layout class that derives from the Layout<T> class, it's not always practical to do so, particularly for the AbsoluteLayout, Grid, and RelativeLayout classes.

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.