WPF - C# Desktop App - DateGrid - IValueConverter
Markus Freitag
3,786
Reputation points
Hello,
The converter is pretty powerful and I can do a lot with it. Perhaps this mechanism is an advantage over WinForms.
When and why do I need this line?
That would be the question of this thread. [ValueConversion(typeof(string), typeof(SolidColorBrush))]
**[ValueConversion(typeof(string), typeof(SolidColorBrush))]**
public class MagazineStateConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if ((value == null || ((string)value).Contains("0")))
return Brushes.Red;
else if ((value == null || ((string)value).ToLower().Contains("empty") || ((string)value).ToLower().Contains("leer")))
return Brushes.Yellow;
else
return Brushes.Green;
}
public class ColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value.GetType() != typeof(ModeState)) return Brushes.Transparent;
switch ((ModeState)value)