Hello,
Welcome to Micorosoft Q&A!
How to get Label Width in Xaml?
Your code is correct, but if you have not specified the label's WidthRequest
, the binding will not work. For your requirement, you need to bind Width
property. Please try the following code.
<Label
x:Name="Hello"
BackgroundColor="Gainsboro"
HorizontalOptions="Center"
Text="This Is Fist Line"
VerticalOptions="Center"
/>
<Label
BackgroundColor="AliceBlue"
HorizontalOptions="Center"
Text="OtherOne"
WidthRequest="{Binding Source={x:Reference Hello}, Path=Width}" />
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.