ChronoFlow/ChronoFlow.View/Converter/BoolToBrushConverter.cs
2025-06-23 07:13:06 +02:00

26 lines
786 B
C#

using System;
using System.Globalization;
using Avalonia.Data.Converters;
using Avalonia.Media;
namespace ChronoFlow.View.Converter
{
public class BoolToBrushConverter : IValueConverter
{
public IBrush TrueBrush { get; set; } = Brushes.Blue;
public IBrush FalseBrush { get; set; } = Brushes.Gray;
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool boolValue && boolValue)
return Brushes.Blue;
return Brushes.Gray;
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException(); // wird i.d.R. nicht benötigt
}
}
}