Custom page and Collection definiton from xaml

Max25Max25 FRMember ✭✭


I am trying to add some element to an ObservableCollection property from xaml.
In a page class "CustomPage" inheriting from ContentPage, I defined a property:

public ObservableCollection<CustomItem> Items { get; set; }

And in xaml I want to add item to this collection:

    <nsp:CustomItem Description="!Desc" />

I'm getting this error: "The given key was not present in the dictionary".

What is the correct syntax to achieve that? I've also tried surrounding it with x:array, or replacing ObservableCollection with List<>...
It seems possible when I look at ContentPage.ToolbarItems which is an ObservableCollection



  • Max25Max25 FRMember ✭✭

    OK I just figured it out. My class CustomItem was missing...... the default (empty) ctor.

Sign In or Register to comment.