How do I change the background color of a XAML textbox depending on value at runtime? These color values can be customized by the end user. Seems I can’t just set the “Background” property.
<TextBox Name="nameInput" Width="300" HorizontalAlignment="Left" />
How would the code behind look to accomplish this? This doesn’t work:
Private Sub NameInput_TextChanged(sender As Object, e As TextChangedEventArgs) Handles nameInput.TextChanged
Select Case nameInput.Text
Case "x"
nameInput.Background = "Red"
Case "y"
nameInput.Background = "Green"
End Select
End Sub
you need to assign
SolidColorBrushinstead of justColor.