4

Windows 手机项目中的 WidthRequest=50 不起作用。在 android 和 iOS 中它正在工作。但在 WinPhone 中只显示半个按钮。我也尝试过使用 MinimumWidthRequest,这也不起作用。

在 windows phone 中,按钮的最小宽度仅为 109。小于 109 WIdthRequest,溢出宽度消失。有谁知道如何在 WinPhone 中修改这个 MinimumWidthRequest?或任何其他解决方案?

<StackLayout VerticalOptions="Center" HorizontalOptions="Center">
    <Label Text="WidthRequest=109" HorizontalTextAlignment="Center" Margin="0,10,0,0"/>
    <Button HorizontalOptions="Center" VerticalOptions="Center" Text="109" HeightRequest="50" WidthRequest="109"/>
    <Label Text="WidthRequest=108"  HorizontalTextAlignment="Center" Margin="0,10,0,0"/>
    <Button HorizontalOptions="Center" VerticalOptions="Center" Text="108" HeightRequest="50" WidthRequest="108"/>
    <Label Text="WidthRequest=70"  HorizontalTextAlignment="Center" Margin="0,10,0,0"/>
    <Button HorizontalOptions="Center" VerticalOptions="Center" Text="70" HeightRequest="50" WidthRequest="70"/>
    <Label Text="WidthRequest=50" HorizontalTextAlignment="Center" Margin="0,10,0,0"/>
    <Button HorizontalOptions="Center" VerticalOptions="Center" Text="50" HeightRequest="50" WidthRequest="50"/>
</StackLayout>

这是 Button 在 Windows Phone 中的显示方式

这就是 Button 在 Android 中的显示方式

4

1 回答 1

4

终于解决了问题,创建CustomRender了Button,定义Control.MinWidth了Button。MinimumWidthRequest在 Xamarin.Forms 中没有按预期工作。

于 2017-03-27T05:27:37.463 回答