mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
42 lines
1.2 KiB
C#
42 lines
1.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Globalization;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Data;
|
|
using System.Windows;
|
|
|
|
namespace Serein.WorkBench.Tool.Converters
|
|
{
|
|
/// <summary>
|
|
/// 根据bool类型控制可见性
|
|
/// </summary>
|
|
[ValueConversion(typeof(bool), typeof(Visibility))]
|
|
public class InvertableBooleanToVisibilityConverter : IValueConverter
|
|
{
|
|
enum Parameters
|
|
{
|
|
Normal, Inverted
|
|
}
|
|
|
|
public object Convert(object value, Type targetType,
|
|
object parameter, CultureInfo culture)
|
|
{
|
|
var boolValue = (bool)value;
|
|
var direction = (Parameters)Enum.Parse(typeof(Parameters), (string)parameter);
|
|
|
|
if (direction == Parameters.Inverted)
|
|
return !boolValue ? Visibility.Visible : Visibility.Collapsed;
|
|
|
|
return boolValue ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
|
|
public object? ConvertBack(object value, Type targetType,
|
|
object parameter, CultureInfo culture)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
}
|