I'm new to Xamarin. When I try to insert a Button or a BoxView I can set the "HeightRequest" and "WidthRequest" Parameters but the elements are just filling the whole screen. What am I doing wrong?
0
votes
1 Answers
1
votes
You have done nothing wrong, but you missed some key procedure. you did not set LayoutOptions of Button or BoxView. The following code could make element size effected.
<Button Text="click me"
HeightRequest="44"
WidthRequest="60"
VerticalOptions="Start"
HorizontalOptions="Start"/>
As you know, the button control is inherited from the View. The default value of VerticalOptions dependency property is LayoutOptions.Fill. And it also works for HorizontalOptions. So if you did not set value for VerticalOptions and HorizontalOptions, the control will fill the whole screen.