mobilecontrols-400555-xamarin-forms-navigation-controls-tab-view-getting-started-how-to-bind-to-itemssource.md
This lesson explains how to create a tab bar that allows end users to filter a list. The lesson uses TabView capability to generate tab items from a data source to build the filtering tab bar:
This lesson populates tab items automatically from an item source. Refer to the Lesson 1 to learn how to manually create tab items.
Note
This lesson requires an empty Xamarin.Forms solution.
DevExpress Navigation components are available for iOS and Android , and can be used in Xamarin.Forms solutions that use the .NET Standard code sharing strategy.
Add DevExpress Navigation components to your solution in one of the following ways:
Add the initialization code to your projects.
Assign a TabView instance to the MainPage’s Content property:
Add the Vehicle class, which represents a data object in the app, to the Xamarin.Forms project:
Create the GroupedVehiclesViewModel class that is a tab item’s view model. This view model contains content displayed by the tab item in the header and in the main area:
Create the MainViewModel class that provides content displayed by the MainPage:
Assign a MapViewModel instance to the MainPage’s BindingContext :
Bind the Tab View’s ItemsSource property to the view model’s VehiclesByMake property, and the SelectedItemIndex property to the view model’s SelectedIndex property in the MainPage.xaml file. Then, specify the ItemHeaderTemplate, which manages the Header Item appearance, and the ItemTemplate, which changes the content appearance.
This step configures the appearance of the Tab View’s header panel and header items:
Specify min and max sizes for items (the ItemHeaderMinWidth and ItemHeaderMaxWidth properties), the spacing between items (HeaderPanelItemSpacing), and item padding:
Modify the header panel background (HeaderPanelBackgroundColor), and bind an item’s background color to a view model state:
Specify the frame’s border radius and margin, configure tab view’s shadow (HeaderPanelShadowHeight and HeaderPanelShadowRadius properties), hide the Selected Item Indicator (IsSelectedItemIndicatorVisible), and customize the label’s text color:
You can clone the complete solution from GitHub.