Crunchy-Downloader/CRD/Utils/UI/UiIntToVisibilityConverter.cs

21 lines
711 B
C#
Raw Normal View History

2024-05-04 15:35:32 +00:00
using System;
using System.Globalization;
using Avalonia.Data.Converters;
using FluentAvalonia.UI.Controls;
namespace CRD.Utils.UI;
public class UiIntToVisibilityConverter : IValueConverter{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture){
if (value is int intValue){
// Return Visible if intValue is greater than or equal to 1, otherwise Collapsed
return intValue >= 1 ? true : false;
}
return false;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){
throw new NotImplementedException("This converter only works for one-way binding");
}
}