Reputation: 29427
I have just started my trial with Xamarin and I am trying to investigate how it works.
I would like to create a simple page with three rows that have the following requirements:
I have tried to create this page directly with code doing something like this:
public SamplePage() {
this.Padding = new Thickness( 10, Device.OnPlatform( 20, 0, 0 ), 10, 0 );
var homeLogo = new Image() {
Aspect = Aspect.AspectFit
};
homeLogo.Source = ImageSource.FromFile( "HomeLogo.png" );
var btn1 = new Button() {
Text = "first button"
};
var btn2 = new Button() {
Text = "second button"
};
this.Content = new StackLayout {
VerticalOptions = LayoutOptions.Center,
HorizontalOptions = LayoutOptions.Center,
Orientation = StackOrientation.Vertical,
Children = {
homeLogo,
new Label {
VerticalOptions = LayoutOptions.FillAndExpand,
Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in dolor maximus, molestie elit quis, condimentum ipsum."
},
btn1,
btn2
}
};
}
I am using Xamarin in Visual Studio and created a Xamarin Forms project using a Portabe class library. Is there any designer that I can use to start learning how to create UI?
Upvotes: 0
Views: 213
Reputation: 11787
Try this the following. i think you are missing the fact that for the inner container to have the ability to expand the parent container should have the same property set to expand as well.
this.Content = new StackLayout {
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.Center,
Orientation = StackOrientation.Vertical,
Children = {
homeLogo,
new Label {
VerticalOptions = LayoutOptions.CenterAndExpand,
Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas in dolor maximus, molestie elit quis, condimentum ipsum."
},
btn1,
btn2
}
};
Upvotes: 1