【发布时间】:2017-09-08 10:33:50
【问题描述】:
我是 Xamarin 的新手。 当我尝试插入 Button 或 BoxView 时,我可以设置“HeightRequest”和“WidthRequest”参数,但元素只是填满了整个屏幕。 我做错了什么?
【问题讨论】:
标签: xaml xamarin uwp xamarin.forms
我是 Xamarin 的新手。 当我尝试插入 Button 或 BoxView 时,我可以设置“HeightRequest”和“WidthRequest”参数,但元素只是填满了整个屏幕。 我做错了什么?
【问题讨论】:
标签: xaml xamarin uwp xamarin.forms
您没有做错任何事,但您错过了一些关键程序。您没有设置 LayoutOptions 或 Button 或 BoxView。以下代码可以影响元素大小。
<Button Text="click me"
HeightRequest="44"
WidthRequest="60"
VerticalOptions="Start"
HorizontalOptions="Start"/>
如您所知,按钮控件继承自View。 VerticalOptions 依赖属性的默认值为LayoutOptions.Fill。它也适用于HorizontalOptions。所以如果你没有为VerticalOptions和HorizontalOptions设置值,控件会填满整个屏幕。
【讨论】: