I was able to this in Xamarin.
Xaml
<ScrollView x:Name="dynamicFormScrollView" VerticalOptions="FillAndExpand">
<StackLayout x:Name="dynamicFormStack"
BindableLayout.ItemTemplateSelector="{StaticResource responseTemplateSelector}"
BindableLayout.ItemsSource="{Binding SurveyList}" Orientation="Vertical"/>
</ScrollView>
Code behind
private void ExecuteUpdateUI(int obj)
{
var elementToBeFocused = dynamicFormStack.Children[obj - 1];
dynamicFormScrollView.ScrollToAsync(elementToBeFocused, ScrollToPosition.Start, true);
}
So this code
dynamicFormStack.Children[index]
returned Element
in Xamarin but it’s returning an IView
object in MAUI. I don’t know how to convert from IView
to Element
or Retrieve the Element
in MAUI.
The objective is to scroll programmatically to an element in a Stack Layout
where a list is binded as BindableLayout.ItemSource