using System; using System.Globalization; using Avalonia.Controls; using Avalonia.Data.Converters; namespace AdvancedCalculator.Converters; public class WidthToSplitViewModeConverter : IValueConverter { public static readonly WidthToSplitViewModeConverter 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 ? SplitViewDisplayMode.Overlay : SplitViewDisplayMode.Inline; } return SplitViewDisplayMode.Inline; } public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo? culture) => throw new NotSupportedException(); }