We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Is it possible to center the SelectedIndex of SfTabView

Thread ID:

Created:

Updated:

Platform:

Replies:

150676 Jan 15,2020 07:40 PM UTC Jan 20,2020 12:59 PM UTC Xamarin.Forms 3
loading
Tags: SfTabView
Matthew Bailey
Asked On January 15, 2020 07:45 PM UTC

In many apps, when given several views to select from in a TabView sort of page, the current selection is often centered in the selector.

With TabView, the current SelectedIndex is only centered when there are tabs to the left or right. If I have 5 tabs, with only three visible at a time, then tab 1 and tab 5 can never be centered, only 2,3 & 4 because there is atleast 1 available tab to the left or the right.

Is there some way to achieve this sort of behavior with SfTabView?

Second question, is it possible to snap to position when fast scrolling?

Praveen Koildasan [Syncfusion]
Replied On January 17, 2020 10:02 AM UTC

Hi Matthew,

Greetings from Syncfusion.

Query 1: "If I have 5 tabs, with only three visible at a time, then tab 1 and tab 5 can never be centered"

Currently, we don't have support for your requirement. The current behaviour is the intended behaviour of SfTabView.

Query 2: "is it possible to snap to position when fast scrolling?"

We are unable to get the exact meaning of your requirement. So, please elaborate your requirement which will help us to provide a better solution on this.

Regards,
Praveen K.


Matthew Bailey
Replied On January 17, 2020 02:42 PM UTC

Query 1:
I can live with that, so to expand on it - is there a way to disallow a tab to be selected, in essence on the Tab level to set something like IsEnabled? Or to deny navigation to a tab if it's tapped?


Query 2:
In my application I have 7 tabs. I have set VisibleHeaderCount = "3", but as I slide the header left to right, or right to left, I can see 4 tabs (as seen in image)


My desire is to have the TabView snap to show only 3 when the user stops the swipe movement. Then if not initially able, I would want to auto select a specific tab upon snapping.

The current implementation keeps the first tab active (or whatever tab is selected) after swiping side-to-side - but I want it to change as swiped as is the standard practice for a viewModel in Android and TabbedPage in Xamarin.

Hemalatha Marikumar [Syncfusion]
Replied On January 20, 2020 12:59 PM UTC

Hi Matthew, 

Thanks for your update.

Query 1: "set something like IsEnabled? Or to deny navigation to a tab if it's tapped?"

 
We have achieved your requirement using the ItemTapped event which is available in SfTabView. Also, we have prepared the sample based on your requirement. Please find the sample from the below link. 

Code Snippet[Xaml] MainPage.Xaml 
<tabView:SfTabView Grid.Row="1" Grid.ColumnSpan="2" x:Name="tabView" TabItemTapped="TabView_TabItemTapped">
             ......
</tabView:SfTabView> 

Code Snippet[C#] MainPage.Xaml.cs
 
private void TabView_TabItemTapped(object sender, TabItemTappedEventArgs e)
{
          
  if (e.TabItem.Title== "Favorites")
                e.Cancel = true; 
 
 
Query 2: "auto-select a specific tab upon snapping."

Whenever a tab item is selected, the selection will not be moved to another item until we tap on it and we confirm that this is the expected behavior of SfTabView.  


 
Query 3: "VisibleHeaderCount = "3", but as I slide the header left to right, or right to left, I can see 4 tabs"

This is the current behavior of SfTabView and we have taken this requirement as improvement of SfTabView. We have logged this as a feature request, and you can track the status of this feature implement through below link 
  
 
Please cast your vote to make it count. We will prioritize the features every release based on the demands and we do not have an immediate plan to implement this feature since we committed with already planned work. So, this feature will be available in any of our upcoming releases.     
   
If you have any more specifications/suggestions to the feature request, you can add it as a comment in the portal.  
 
Regards, 
Hemalatha M. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon