BililiveRecorder/BililiveRecorder.WPF/Converters/BoolToValueConverter.cs

31 lines
794 B
C#
Raw Normal View History

2020-11-27 18:51:02 +08:00
using System;
using System.Globalization;
using System.Windows.Data;
namespace BililiveRecorder.WPF.Converters
{
internal class BoolToValueConverter : IValueConverter
{
public object FalseValue { get; set; }
public object TrueValue { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
{
return FalseValue;
}
else
{
return (bool)value ? TrueValue : FalseValue;
}
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return value != null ? value.Equals(TrueValue) : false;
}
}
}