1

I would like to use the flex layout binding itemsource without the real binding. I would like to generate the list data from behind the page c# . I had to do it since this page is loading 6 more different lists with different data sources and for a reason, I don't know the binding is not getting into the view, so I decided to move all the list results to the page behind and display all the other lists.

This is what I have

xaml

                        <FlexLayout x:name="painfullist" BindableLayout.ItemsSource="{Binding List}">
                              <BindableLayout.ItemTemplate>
                                  <DataTemplate>
                                     <Button Padding="20" CornerRadius="25" Text="{Binding Value}" />
                                     </DataTemplate>
                              </BindableLayout.ItemTemplate>
                        </FlexLayout>

c# I tried to bind with the view model but the data just dont show up. so my plan b is to get it from behind the page.

BindingContext = vm;

var getamenities = vm.Amenities;

painfullist.ItemsSource = new List<Amenitys>(getamenities);
Pxaml
  • 651
  • 2
  • 12
  • 38

1 Answers1

1

ItemsSource is an attached property in the BindableLayout class, to set it in code for the BindableObject (FlexLayout):

BindableLayout.SetItemsSource(painfullist, vm.Amenities); //Amenities better to be ObservableCollection
mshwf
  • 7,009
  • 12
  • 59
  • 133