using System; using System.Globalization; using Avalonia.Data.Converters; namespace AdvancedCalculator.Converters; public class WidthToPaneOpenConverter : IValueConverter { public static readonly WidthToPaneOpenConverter Instance = new(); public object? Convert(object? value, Type targetType, object? parameter, CultureInfo? culture) { if (value is double width) { double threshold = 640; if (parameter is double p) threshold = p; else if (parameter is string s && double.TryParse(s, NumberStyles.Number, CultureInfo.InvariantCulture, out var parsed)) threshold = parsed; return width >= threshold; } return true; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo? culture) => throw new NotSupportedException(); }