Sharpnado.Tabs
Sharpnado.Tabs copied to clipboard
[MAUI] Auto-scroll selected tab into view
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):
Does anyone know how to implement this now ?