【问题标题】:RepeaterView<T> in Xamarin Forms LabsXamarin Forms Labs 中的 RepeaterView<T>
【发布时间】:2014-10-23 19:35:34
【问题描述】:

我正在尝试找出 Xamarin Forms Labs 中的 RepeaterView。

背景

我有一个名为 Entry 的简单实体,它有一个名为 Notes 的属性

class Entry
{
    public string Notes { get; set; }
}

在通用 PCL 中,我继承自 RepeaterView 以使其非泛型。

class EntryRepeater : Xamarin.Forms.Labs.Controls.RepeaterView<MyKids.Core.Entities.Entry>
{
}

我尝试使用转发器的页面的 XAML 如下所示

<rep:EntryRepeater ItemsSource="{Binding Entries}">
    <rep:EntryRepeater.ItemTemplate>
      <DataTemplate>
        <ViewCell>
          <ViewCell.View>
            <StackLayout>
               <Label Text="{Binding Notes}" />
            </StackLayout>
          </ViewCell.View>
        </ViewCell>
      </DataTemplate>
    </rep:EntryRepeater.ItemTemplate>
   </rep:EntryRepeater >

其中 Entries 是 ObservableCollection。

问题

问题在于 DataTemplate 中的绑定似乎指向主模型,而不是集合中的一项。但是它重复了正确的次数。

[0:] Binding: 'Notes' property not found on 'MyApp.ViewModels.EntryListViewModel', target property: 'Xamarin.Forms.Label.Text'

【问题讨论】:

  • 不能在 xaml 上作为非泛型使用吗?我只能看到带有 c# 代码的示例,但不能看到 xaml。
  • 我认为你必须使用泛型。但您也可以在 Xaml 中指定类型参数。对于上面的示例,类似于

标签: xaml xamarin.forms


【解决方案1】:

回到这个问题,这实际上是早期版本的 Xlabs 中的一个错误。它现在已修复,上面的代码确实有效。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-13
    • 1970-01-01
    • 2014-09-20
    • 2015-02-26
    • 2023-03-22
    • 2015-09-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多