Reputation: 1
I am using visual studio 2017, I created a shared project with portable class library, I added the following code in to MainPage.xaml.cs class file,
var scroll = new ScrollView();
Content = scroll;
var stack = new StackLayout();
stack.Children.Add(new BoxView { BackgroundColor = Color.Red, HeightRequest = 600, WidthRequest = 600 });
stack.Children.Add(new Entry());
content=stack ;
then I deployed the project, and run it in local machine, I found that the scrolling is not working. what am I missing in here? Any help please. Thanks.
Upvotes: 0
Views: 1450
Reputation: 33993
You're not adding the stack
to the scroll. Edit it like this:
var scroll = new ScrollView();
var stack = new StackLayout();
stack.Children.Add(new BoxView { BackgroundColor = Color.Red, HeightRequest = 600, WidthRequest = 600 });
stack.Children.Add(new Entry());
// Note how I add the stack object to the ScrollView here
scroll.Content = stack;
// And add the ScrollView to the Content of the page instead of the stack
Content = scroll;
Upvotes: 1
Reputation: 628
Try this
var stack = new StackLayout();
stack.Children.Add(new BoxView { BackgroundColor = Color.Red, HeightRequest = 600, WidthRequest = 600 });
stack.Children.Add(new Entry());
Content = new ScrollView { Content = stack }
Upvotes: 0