How to change text of a label

Hi, i'm simply trying to change the text in a label from the code behind it. I am quite new to xamarin. In wpf I would have just written myLabel.Text = variable. Is this possible in Xamarin as all my previous attempts have not worked?

Answers

  • AlessandroCaliaroAlessandroCaliaro ITMember ✭✭✭✭✭
    Yes It should work
  • blearibleari Member ✭✭

    This is my backend code that is run Label_ControlSW.Text = controlSW_Out. It is located in mainpage.xaml.cs

    This is my xaml <Label x:Name="Label_ControlSW" Grid.Row="1" Grid.Column="1" HorizontalOptions="Center" VerticalOptions="Center" FontSize="17" TextColor="White"/> <Label x:Name="Label_BLESW" Grid.Row="2" Grid.Column="1" HorizontalOptions="Center" VerticalOptions="Center" FontSize="17" TextColor="#525252"/>

    Yet when I run the code the screen stays the same. I am running android 7.1

  • M_Shah04M_Shah04 USMember ✭✭✭

    Is your Label is inside a ListView ? , if that's the case then you can't directly set the label's text like this, you need to find any event and by accessing that in code behind, you can find your label control and change its text.

Sign In or Register to comment.