简体   繁体   English

如何在Windows Phone的Xamarin.Forms中将WidthRequest = 50设置为按钮?

[英]How to set WidthRequest=50 to button in Xamarin.Forms for Windows Phone?

WidthRequest=50 in Windows phone project not working. Windows Phone项目中的WidthRequest = 50无法正常工作。 In android and iOS it is working. 在Android和iOS中,它正在运行。 But in WinPhone displaying only half button. 但在WinPhone中只显示半按钮。 I tried with MinimumWidthRequest also, that also not working. 我也试过了MinimumWidthRequest,也没用。

Button takes MinimumWidth of only 109 in windows phone. 在Windows手机中,Button的MinimumWidth仅为109。 Less than 109 WIdthRequest, disappears overflowed width. 小于109 WIdthRequest,消失溢出的宽度。 Does anybody knows how to modify this MinimumWidthRequest in WinPhone? 有人知道如何在WinPhone中修改此MinimumWidthRequest吗? or Any other solution for this? 或任何其他解决方案?

<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>

This is how Button displays in Windows Phone 这就是Button在Windows Phone中的显示方式

This is how Button displays in Android 这就是Button在Android中的显示方式

Finally solved the problem, Created CustomRender of Button and defined Control.MinWidth for Button. 最后解决了问题,创建了Button的CustomRender并为Button定义了Control.MinWidth MinimumWidthRequest not working as expected in Xamarin.Forms. MinimumWidthRequest在Xamarin.Forms中无法正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM