1
votes

I'm trying to figure out the RepeaterView in Xamarin Forms Labs.

THE BACKGROUND

I have a simple entity called Entry that has property called Notes

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

In the common PCL, I've inherited from the RepeaterView to make it non-generic.

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

And the XAML of the page where I'm trying to use the repeater looks like this

<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 >

where Entries is an ObservableCollection.

THE ISSUE

The problem is that the binding in the DataTemplate seems to point to the main model and not to one item in the collection. BUT it is repeated the correct number of times.

[0:] Binding: 'Notes' property not found on 'MyApp.ViewModels.EntryListViewModel', target property: 'Xamarin.Forms.Label.Text'
1
Is it not possible to use it as non-generic on xaml? I can only see example with c# code but not with xaml.Emil
I think you have to use generics. But you can specify the type argument in Xaml as well. Something like <labs:RepeaterView x:TypeArguments="MyApp.ViewModels.EntryListViewModel"> for the example above.Johan Karlsson

1 Answers

0
votes

To circle back to this question, this was actually an error in earlier versions of Xlabs. It's now fixed and the code above does work.