C# WPF ViewModel change background color for textbox

Markus Freitag 3,786 Reputation points
2020-07-16T09:50:49.357+00:00
 <TextBox   Name="txtSlot" Text="{Binding Path=GebindeSlot, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  Height="33" Margin="22,376,183,232" Grid.Column="3"        />

Hello,
How can I change the background color from the code?
If GebindeSlot.length == 0
White
else
Green.

Thanks!

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,691 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. DaisyTian-1203 11,616 Reputation points
    2020-07-17T03:45:28.89+00:00

    You can set your TextBox like below:
    12802-capture.png

    1 person found this answer helpful.
    0 comments No comments