0
votes

I am building a Xamarin Forms app and on one of the screens, I am populating a ListView using an ObservableCollection. The ItemTemplate is selected using a DataTemplateSelector class which is being hit during debugging and returning a DataTemplate. However I am not seeing the template displaying on the form when it is opened. I am currently doing my debugging using the UWP interface.

So far, I've tried adding a ListView that has a simple label item template which also doesn't appear to be working as well. I see that there is a list view item in the Visual Tree though it only contains a ListViewItemPresenter which contains a CellControl.

The property I am binding to is:

public Generators.Parameter.ConfigurationList Parameters { get; }

ConfigurationList inherits ObservableCollection:

public class ConfigurationList : ObservableCollection<Configuration>

The xaml to display a simple ListView is:

<ListView ItemsSource="{Binding Parameters}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <Label Text="Test" />
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

The full source is available on github here TheRandomizer.Mobile

1

1 Answers

0
votes

Immediately after submitting my question I figured it out but thought I would leave it in case anyone else runs into this. The DataTemplate requires a :

<ListView ItemsSource="{Binding Parameters}">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Label Text="Test" />
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>