using Xamarin.Forms; namespace MyApp { public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); } } }
using Xamarin.Forms; namespace MyApp { public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); //Adding StackLayout to ContentPage StackLayout contentLayout = new StackLayout(); contentLayout.Children.Add(new Label { Text = "Hello World!" }); Content = contentLayout; } } }
using Xamarin.Forms; namespace MyApp { public partial class MainPage : ContentPage { public MainPage() { InitializeComponent(); //Adding ScrollView to ContentPage ScrollView scrollView = new ScrollView(); StackLayout contentLayout = new StackLayout(); contentLayout.Children.Add(new BoxView { Color = Color.Red, HeightRequest = 200, WidthRequest = 200 }); contentLayout.Children.Add(new BoxView { Color = Color.Blue, HeightRequest = 200, WidthRequest = 200 }); scrollView.Content = contentLayout; Content = scrollView; } } }In this example, a ScrollView is added to the ContentPage. A StackLayout is created and two BoxViews of different colors and sizes are added to it. The StackLayout is then added to the ScrollView and the ScrollView is set as the Content of the ContentPage. Package/library used: Xamarin.Forms