Sharpnado.Tabs icon indicating copy to clipboard operation
Sharpnado.Tabs copied to clipboard

[MAUI] Auto-scroll selected tab into view

Open maxchu92 opened this issue 1 year ago • 1 comments

Is your feature request related to a problem? Please describe. Selected tab is hidden from the display in a scrollable tab, when SelectedIndex is changed.

Describe the solution you'd like When changing the SelectedIndex value, the TabHostView should auto scroll and center (if applicable) the selected tab into display.

Describe alternatives you've considered Adding an API to manually scroll the tab into view. Example:

//Code to execute
    await TabHostView.ScrollToAsync(3, ScrollToPosition.Center, true);
public async Task ScrollToAsync(double x, double y, bool isAnimated){
    //scroll to position
    await _scrollView.ScrollToAsync(x, y, isAnimated);
}

public async Task ScrollToAsync(int selectedIndex, ScrollToPosition position, bool isAnimated){
    var selectedTab = this.Children().FirstOrDefault(x = true); //Look for selectedTab
    await _scrollView.ScrollToAsync(selectedTab, position, isAnimated);
}

Additional context Example:

Current Behavior:

Scroll the selected tab into view:

Scroll the selected tab into view, and adjust to center (If enough space is available):

maxchu92 avatar Apr 28 '23 07:04 maxchu92

Does anyone know how to implement this now ?

AntonUA86 avatar Nov 29 '23 08:11 AntonUA86