There is a funny bug in the current version of .Net Maui. This occurs on Android and when a stacklayout wants to scroll. This works great the first time, however it happens that the second time the page just stays blank. It is best to use a grid.
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Xaml;
namespace MyApp
{
[XamlCompilation(XamlCompilationOptions.Compile)]
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
// Create the ScrollView
var scrollView = new ScrollView();
// Create the StackLayout
var stackLayout = new StackLayout();
// Add some content to the StackLayout
for (int i = 1; i <= 20; i++)
{
var label = new Label
{
Text = $"Item {i}",
FontSize = 20,
HorizontalOptions = LayoutOptions.Center
};
stackLayout.Children.Add(label);
}
// Set the StackLayout as the content of the ScrollView
scrollView.Content = stackLayout;
// Set the ScrollView as the content of the page
Content = scrollView;
}
}
}