Delpin Susai Raj Sunday, 24 November 2019

Xamarin.Forms - Bindable Layout

In this blog post, you will learn how to use Bindable Layout in Xamarin.Forms.

Xamarin.Forms code runs on multiple platforms - each of which has its own filesystem. This means that reading and writing files is most easily done using the native file APIs on each platform. Alternatively, embedded resources are a simpler solution to distribute data files with an app.

Bindable Layout

Bindable layouts enable any layout class that derives from the Layout<T> class to generate its content by binding to a collection of items, with the option to set the appearance of each item with a DataTemplate. Bindable Layout it's like a ListView.

Bindable Layout Attached properties.
  1. ItemsSource – Gets sets the collection of IEnumerable items to template and display.
  2. ItemDataTemplate – Gets sets DataTemplate to apply to each item in the collection of items displayed layout.
  3. ItemTemplateSelector – DataTemplateSelector that will be used to choose a DataTemplate for an item at runtime.
  • Visual Studio 2017 or later (Windows or Mac)
Setting up a Xamarin.Forms Project

Start by creating a new Xamarin.Forms project. You wíll learn more by going through the steps yourself.

Create a new or existing Xamarin forms(.Net standard) Project. With Android and iOS Platform.
Bindable Layout

Lets start with how to use Bindable layout in your app instead of listview.

Use Bindable Layout

In this step, use bindable layout in Stacklayout.


Create a Model

Now, Create a simple model to create a collection.


Create a ViewModel

In this step, create a viewmodel to bind the collection to bindable layout.


Selected Item

Use GestureRecognizers for select item from collection, because bindable layout have no ItemSelected event.



Try it out.
I hope you have understood how to use Bindable Layout in Xamarin.Forms..

Thanks for reading. Please share your comments and feedback. Happy Coding :)

1 comment:

  1. Thank you so much for sharing this excellent information. Your article is amazing. Good to discover your post

    Hire Xamarin Developer Texas, USA