简体   繁体   English

FlexLayout 可绑定源-xamarin 表单-如何在不绑定的情况下获取数据

[英]FlexLayout bindable source -xamarin forms - how to get data without binding

I would like to use the flex layout binding itemsource without the real binding.我想使用没有真正绑定的 flex 布局绑定 itemsource。 I would like to generate the list data from behind the page c# .我想从页面 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.我不得不这样做,因为这个页面正在加载 6 个不同数据源的不同列表,出于某种原因,我不知道绑定没有进入视图,所以我决定将所有列表结果移到后面的页面并显示所有其他列表。

This is what I have这就是我所拥有的

xaml xml

                        <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. c#我试图与视图模型绑定,但数据只是不显示。 so my plan b is to get it from behind the page.所以我的计划 b 是从页面后面获取它。

BindingContext = vm;

var getamenities = vm.Amenities;

painfullist.ItemsSource = new List<Amenitys>(getamenities);

ItemsSourceBindableLayout类中的一个附加属性,用于在BindableObject (FlexLayout) 的代码中设置它:

BindableLayout.SetItemsSource(painfullist, vm.Amenities); //Amenities better to be ObservableCollection

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM