ChronoFlow/ChronoFlow.View/Converter/BoolToBrushConverter.cs
2025-06-21 11:32:41 +02:00

24 lines
721 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 b)
return b ? TrueBrush : FalseBrush;
return FalseBrush;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
throw new NotSupportedException();
}
}