WIn_RustTools/RustTools/Services/BooleanToVisibilityConverter.cs
2024-08-24 19:50:04 +08:00

27 lines
614 B
C#

using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
namespace RustTools.Services;
public class BooleanToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return string.IsNullOrEmpty(value.ToString()) ? Visibility.Collapsed: Visibility.Visible;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
if (value is Visibility visibility)
{
return visibility == Visibility.Visible;
}
return false;
}
}