Reputation: 49
I am using a box view to underline some text in Xamarin and I want to set the width of the box view to the width of the label
Upvotes: 0
Views: 1006
Reputation: 55
Label has a property TextDecorations. You can set it to Underline to underline a text without using BoxView.
<Label Text="Your Text" TextDecorations="Underline">
Upvotes: 3
Reputation: 1474
Define WidthRequest for the Label and bind that to the Box view as shown below.
<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>
Upvotes: 3