I have an issue with displaying items in a list view. I have tried to add Mode= twoway, oneway or default.
I have checked the binding
<ListView x:Name="list"
HasUnevenRows="True"
IsPullToRefreshEnabled="True"
HorizontalOptions="CenterAndExpand"
VerticalOptions="FillAndExpand"
VerticalScrollBarVisibility="Never"
CachingStrategy="RecycleElement"
ItemsSource="{Binding DateFormatList}"
SeparatorVisibility="Default" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Label Text="{Binding DateType}" TextColor="black" HorizontalOptions="Start" FontSize="14" HorizontalTextAlignment="Center" ></Label>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Back of my page
public DateSettings()
{
InitializeComponent();
BindingContext = new CustomSettingsViewModel();
}
My Ctor in the view model
public List<DateFormat> DateFormatList { get; private set; }
public CustomSettingsViewModel()
{
DateFormatList = new List<DateFormat>();
DateFormatList.Add(new DateFormat
{
DateType = "yy/dd/mm",
});
}
Model
public class DateFormat
{
public string DateType;
}
you can only bind to public properties
public class DateFormat
{
public string DateType { get; set; }
}