简体   繁体   中英

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

WidthRequest=50 in Windows phone project not working. In android and iOS it is working. But in WinPhone displaying only half button. I tried with MinimumWidthRequest also, that also not working.

Button takes MinimumWidth of only 109 in windows phone. Less than 109 WIdthRequest, disappears overflowed width. Does anybody knows how to modify this MinimumWidthRequest in WinPhone? 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

This is how Button displays in Android

Finally solved the problem, Created CustomRender of Button and defined Control.MinWidth for Button. MinimumWidthRequest not working as expected in Xamarin.Forms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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