I saw an article on xamarin forms with some "Bindable love" https://blog.xamarin.com/xamarin-forms-3-5-a-little-bindable-love/.
I wanted to try it out and create a scrolling list but for some reason, the data that i am binding does not seem to appear in the view. The binding should work fine because in my XAML i bind plenty of other things and it works successfully, but for some reason this particular binding is not working.
XAML:
<ScrollView>
<StackLayout BackgroundColor="Transparent" BindableLayout.ItemsSource="{Binding CategoriesList}" >
<BindableLayout.ItemTemplate>
<DataTemplate>
<StackLayout Orientation = "Horizontal" HeightRequest="150" WidthRequest="80">
<Button Text="{Binding Name}" />
</StackLayout>
</DataTemplate>
</BindableLayout.ItemTemplate>
</StackLayout>
</ScrollView>
This is how my list looks in the VM:
private ObservableCollection<Categories> _Categories;
public ObservableCollection<Categories> CategoriesList
{
get
{
return this._Categories;
}
set
{
if (_Categories != value)
{
this._Categories = value;
RaisePropertyChanged("CategoriesList");
}
}
}
And when i create data to it:
CategoriesList = new ObservableCollection<Categories>();
CategoriesList.Add(new Categories() { Name = "Data 1", ID = "1" });
CategoriesList.Add(new Categories() { Name = "Data 2", ID = "2" });
CategoriesList.Add(new Categories() { Name = "Data 3", ID = "3" });