How to bind the text color of the Label using the Relay command.

BalasubramanianSundararajanBalasubramanianSundararajan USMember ✭✭
edited February 2017 in Xamarin.Forms

Hi Team,

Query on bindings in Xamarin platform:

We have created a simple sample to bind the TextColor for the Label using RelayCommand binding in Xamarin.Forms and found that the text color is not changed to the Label.

Can anyone suggest me what I am doing wrong?



public Color BackColor { get { return backColor; } set { backColor = value; RaisePropertyChanged(); } }

public RelayCommand ChangeColor
            return changeColor
                ?? (changeColor = new RelayCommand(
                () =>
                    BackColor = Color.Red;
    } `

Xaml Code:

<Grid> <Grid.RowDefinitions> <RowDefinition Height="50"/> <RowDefinition Height="*"/> <RowDefinition Height="50"/> </Grid.RowDefinitions> <Label Text="Text" TextColor="{Binding BackColor}" Grid.Row="0"/> <Button Text="Change Color" Command="{Binding ChangeColor}" Grid.Row="1" /> </Grid>

**Note: ** I am using MVVMLight nuget for relay command

Sign In or Register to comment.