How to change the border color of a TextBox in a Windows Phone 8.1 app?

1

In a given code function of .cs in C# I need to change the border color of a TextBox . In my xaml I have TextBox

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

And in cs I have 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?

    
asked by anonymous 31.08.2014 / 05:32

1 answer

1

Use the BorderBrush property of the TextBox class:

    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);
        }
    }
    
31.08.2014 / 22:54