Use multibinding for receipt date format

This commit is contained in:
2026-04-08 22:16:56 +09:00
parent 58c59dfc0a
commit 4d89e49c96
2 changed files with 39 additions and 3 deletions
+27
View File
@@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using Avalonia.Data.Converters;
namespace MayShow.Helpers;
public class DateFormatConverter : IMultiValueConverter
{
public object? Convert(
IList<object?> values,
Type targetType,
object? parameter,
CultureInfo culture)
{
if (values.Count >= 2 && values[0] is DateOnly date && values[1] is string format)
{
return date.ToString(format);
}
if (values.Count >= 2 && values[0] is string dateFormat && values[1] is DateOnly dateOnly)
{
return dateOnly.ToString(dateFormat);
}
return 0.0;
}
}