Hi,
I would like to create a stacklayout control filled with controls using C# and then wrap this stacklayout inside a ScrollView. My code is as below.
public partial class MainPage : ContentPage
{
public MainPage()
{
InitializeComponent();
this.Content = this.BuildView();
}
private Layout BuildView()
{
StackLayout stackHeaderInv = new StackLayout()
{
Padding = new Thickness(0, 10),
HorizontalOptions = LayoutOptions.FillAndExpand,
BackgroundColor = "Gray" ,
};
//Custom control definition
...
Button btnComplete = new Button() { Text = "Order Complete", HorizontalOptions = LayoutOptions.Center};
btnComplete.Clicked += btnComplete_Clicked;
stackHeaderInv.Children.Add(CustomControl);
StackLayout stackAll = new StackLayout()
{
Padding = 0,
Spacing = 0,
Children =
{ stackHeaderInv, btnComplete }
};
return stackAll;
}
Now I would like to add more controls to the stacklayout and so I need to use a ScrollView to scroll this page. I would like to know how to add the ScrollView to this BuildView() method in C#. Due to some reason I am not able to create this page with XAML and so have to use C# to create the page.
Thanks.
Rajesh.