How do I change the border color of a Textbox in a Windows Phone 8.1 app?

Asked

Viewed 2,006 times

1

In a certain function of the .cs in C# need to change the color of the edge of a TextBox. In my xaml have the TextBox

<TextBox Name="txtResult" Text="resultado"/>

And in the cs have the validation

private void btnOk_Click(object sender, RoutedEventArgs e)
{
    if (int.Parse(txtResult.Text) == 1){
    //mudar a cor da borda para verde
    } else {
    //mudar a cor da borda para vermelho
    }
}

How can I make this change?

1 answer

1

Use the property BorderBrush class TextBox:

    private void btnOk_Click(object sender, RoutedEventArgs e)
    {
        if (txtResult.Text == "1")
        {
            this.txtResult.BorderBrush = new SolidColorBrush(Colors.Green);
        }
        else
        {
            this.txtResult.BorderBrush = new SolidColorBrush(Colors.Red);
        }
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.