mirror of
https://github.com/BililiveRecorder/BililiveRecorder.git
synced 2024-11-16 11:42:22 +08:00
31 lines
794 B
C#
31 lines
794 B
C#
|
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;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|