19 lines
613 B
C#
19 lines
613 B
C#
using System.Globalization;
|
|
using System.Windows;
|
|
using System.Windows.Data;
|
|
|
|
namespace Livia.Views.Converters;
|
|
|
|
[ValueConversion(typeof(int), typeof(FontWeight))]
|
|
public class IntToFontWeightConverter : IValueConverter
|
|
{
|
|
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
return FontWeight.FromOpenTypeWeight(value is not int i ? 16 : i);
|
|
}
|
|
|
|
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
return value is not FontWeight fontWeight ? 0 : fontWeight.ToOpenTypeWeight();
|
|
}
|
|
} |