Xamarin表单我的列表视图显示空白页面

时间:2018-01-29 05:59:20

标签: xamarin.forms

的Json

swipe_container.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
        @Override
        public void onScrollChanged() {
            if (parentPanelLL.getScrollY() == 0) {
                swipe_container.setEnabled(true);
            } else {
                swipe_container.setEnabled(false);
            }
        }
    });

的ListView

   [
                    {
                        "_id": "5a6736a55c720e4593f74236",
                        "indigentApplicationDetails": {
                            "conditionsDetail": {
                                "foodDetail": {
                                    "rating": {}
                                },
                                "clothingDetail": {
                                    "rating": {}
                                },
                                "medicalDetail": {
                                    "rating": {}
                                },
                                "shelterDetail": {
                                    "rating": {}
                                }
                            },
                            "householdDetail": [
                                {
                                    "currentApplicationRefNo": "1000048573",
                                    "personDetail": {
                                        "gender": "Male",
                                        "surname": "Khabanya",
                                        "initials": "S G",
                                        "genderDisplay": "Male",
                                        "personID": "125555",
                                        "firstNames": "Siphiwo Gift",
                                        "title": "37",
                                        "relationship": "Other",
                                        "titleDisplay": "Mr",
                                        "idNo": "6706115835080",
                                        "birthDate": "1967-06-11 00:00:00"
                                    },
                                    "incomeDetail": {
                                        "amount": "0",
                                        "budgetDetail": {
                                            "otherIncome": "0",
                                            "totalPersonIncome": "0",
                                            "accountHolder": "true",
                                            "propertyRenting": "0",
                                            "uif": "0",
                                            "previousWorkPension": "0",
                                            "homeBusiness": "0.0",
                                            "oldAgePension": "0",
                                            "disabilityPension": "0.0"
                                        }
                                    },
                                    "workSituationDetail": {
                                        "skillCurrentDetail": {
                                            "skillDetail": {}
                                        },
                                        "employmentDetail": {},
                                        "skillDesiredDetail": {
                                            "skillDetail": {}
                                        },
                                        "workDuration": "0"
                                    },
                                    "healthDetail": {
                                        "mentalDefect": "false",
                                        "disability": "false",
                                        "poorHealthDetails": "0"
                                    }
                                }
                            ]

代码

<ListView
                                HasUnevenRows="True"
                                ItemsSource="{Binding ItemsSource}">
                            <ListView.ItemTemplate>
                                <DataTemplate>
                                    <ViewCell>
                                        <Label TextColor="White" Text="{Binding IndigentApplicationDetails.householdDetail.currentApplicationRe‌​fNo}"/>
                                    </ViewCell>
                                </DataTemplate>
                            </ListView.ItemTemplate>
                        </ListView>

2 个答案:

答案 0 :(得分:1)

有几个原因导致您在屏幕上看不到任何内容:

  1. Wring Binding上下文:您使用的是for layer in model.layers[:15]: layer.trainable = False ,但ItemsSource="{Binding ItemsSource}"中没有名为ItemsSource的此类属性。你应该绑定IndigentDetailsViewModels
  2. Cell Binding是错误的。 IndigentDetails应为Text="{Binding IndigentApplicationDetails.householdDetail.currentApplicationRe‌​fNo}"
  3. 错误的文字颜色:大多数平台的细胞都有白色背景颜色。如果你的文字颜色为白色,它将是不可见的。

答案 1 :(得分:0)

请检查下面的xaml代码并检查它是否确实适合你

 <ListView HasUnevenRows="True" ItemsSource="{Binding IndigentDetails}">
       <ListView.ItemTemplate>
           <DataTemplate>
               <ViewCell>
                    <StackLayout Padding="10">
                       <Label Text="{Binding currentApplicationRe‌​fNo}"/>
                    </StackLayout>
               </ViewCell>
           </DataTemplate>
       </ListView.ItemTemplate>
    </ListView>