Hi Markus,
you can use Converter.
public class ViewModel
{
public int Value { get; set; } = 0;
}
public class TextBoxConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType == typeof(Brush))
return (value.GetType() == typeof(int) && (int)value == 0) ? Brushes.Red : Brushes.White;
return (targetType == typeof(string) && (int)value == 0) ? "" : value.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
(value == null || string.IsNullOrEmpty(value.ToString())) ? 0: value;
}