Mvvm ViewCell未绑定

Mvvm ViewCell未绑定,mvvm,xamarin,xamarin.forms,Mvvm,Xamarin,Xamarin.forms,在我的xaml页面上有以下带有绑定的listView。我正在从viewModel将数据绑定到它。但是这些值不绑定到单元格 <ListView x:Name="historyList" ItemsSource="{Binding History}" HasUnevenRows="true"> <ListView.ItemTemplate> <DataTemplate> <ViewCell> &

在我的xaml页面上有以下带有绑定的listView。我正在从viewModel将数据绑定到它。但是这些值不绑定到单元格

 <ListView x:Name="historyList" ItemsSource="{Binding History}" HasUnevenRows="true">
    <ListView.ItemTemplate>
      <DataTemplate>
        <ViewCell>
          <ViewCell.View>
            <StackLayout Orientation="Horizontal" Padding="10, 5, 10, 5" Spacing="0" HorizontalOptions="FillAndExpand" >
              <Label Text="{Binding History.DayNumber}" HorizontalOptions="Center" FontSize="15" TextColor="Red" VerticalOptions="Center"></Label>
            </StackLayout>
          </ViewCell.View>
        </ViewCell>
      </DataTemplate>
    </ListView.ItemTemplate>
  </ListView>

假设
历史
是一个静态变量:

ItemsSource="{x:Static local:History}">
和变化:

{Binding History.DayNumber}
致:

绑定基础:

假设
历史
是一个静态变量:

ItemsSource="{x:Static local:History}">
和变化:

{Binding History.DayNumber}
致:

绑定基础:

您将在调试输出中看到如下警告:

在“..CheckInHistoryItem”上未找到绑定:“DayNumber”属性,目标属性:“Xamarin.Forms.Label.Text”

属性必须是C#属性。把你的课改成

公共类CheckInHistoryItem
{
公共字符串DayText{get;set;}
公共字符串DayNumber{get;set;}
公共字符串检查时间{get;set;}
在{get;set;}中检查公共布尔值
}
并使用
DayNumber
而不是
History.DayNumber

<Label Text="{Binding DayNumber}" HorizontalOptions="Center" FontSize="15" TextColor="Red" VerticalOptions="Center"></Label>

您将在调试输出中看到如下警告:

在“..CheckInHistoryItem”上未找到绑定:“DayNumber”属性,目标属性:“Xamarin.Forms.Label.Text”

属性必须是C#属性。把你的课改成

公共类CheckInHistoryItem
{
公共字符串DayText{get;set;}
公共字符串DayNumber{get;set;}
公共字符串检查时间{get;set;}
在{get;set;}中检查公共布尔值
}
并使用
DayNumber
而不是
History.DayNumber

<Label Text="{Binding DayNumber}" HorizontalOptions="Center" FontSize="15" TextColor="Red" VerticalOptions="Center"></Label>


历史记录是否为静态变量?它是如何定义的?
History
是一个可观察的集合吗?
History
是一个静态变量吗?它是如何定义的?历史是一个可观察的集合吗?历史是什么类型的?