我正在使用框视图在Xamarin中的某些文本下划线,我想将框视图的宽度设置为标签的宽度
答案 0 :(得分:3)
标签具有属性 TextDecorations 。您可以将其设置为 下划线 ,以在不使用BoxView的情况下对文本加下划线。
<Label Text="Your Text" TextDecorations="Underline">
答案 1 :(得分:2)
为Label定义WidthRequest并将其绑定到Box视图,如下所示。
<StackLayout Padding="0,10" HorizontalOptions="Center" VerticalOptions="Center" Orientation="Horizontal">
<Button x:Name="BtnSend" Clicked="BtnSend_Clicked" Text="Send" WidthRequest="150" />
<Label Text="Hello" BackgroundColor="Yellow" WidthRequest="{Binding WidthRequest, Source={x:Reference BtnSend}}" />
</StackLayout>
答案 2 :(得分:0)