Segmented Bar Control in Xamarin Forms

I have always wanted to create a section bar similar to the one that Facebook mobile app has for showing different content in Facebook groups (Dicussion,Photos,Events,etc.). So decided to create custom segmented bar control for Xamarin Forms, which can be used to filter elements, as a tabbed bar or just to show multiple options or content depending on the selected one.

How to use the Control:

Let’s see the code

As you can see here we have seven main properties:

  • Children : A string list of item names
  • ItemSelected : To set the item selected
  • TextColor : To set the TextColor
  • SelectedLineColor : To set the selected line bottom color
  • SelectedTextColor : To set the selected item text color
  • AutoScroll : To scroll automatically and make item visible or not, by default it’s true
  • ValueChanged : Is an event that indicates when item selected changes

Also, for scrolling I’m using internally a custom control called ScrollViewWithNotBar which inherits from ScrollView to hide the scroll bar on each platform by using custom renderers for rendering this control on iOS and Android.

You can find the source for the renderers and control here:

For each children I’m using a Label and a BoxView, adding both to a layout to represent each item and finally adding them to a layout inside a scrollview.

You can find the full source code here:

Happy segmenting!

责编内容来自:Rendy's Website (源链) | 更多关于

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 移动开发 » Segmented Bar Control in Xamarin Forms

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录