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. Image for the cookie policy date

Is it possible to center the SelectedIndex of SfTabView

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?

3 Replies

PK Praveen Koildasan Syncfusion Team 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.



MB Matthew Bailey 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.


HM Hemalatha Marikumar Syncfusion Team 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. 


Loader.
Live Chat Icon For mobile
Up arrow icon