Files
modernkeepass/WinAppCommon/Converters/TextToWidthConverter.cs
Geoffroy BONNEVILLE 73670e8689 Create a shared project with all Win App common files (8.1 and 10)
Finally use the dependency injected Resource Service
2020-04-17 16:56:07 +02:00

21 lines
590 B
C#

using System;
using Windows.UI.Xaml.Data;
namespace ModernKeePass.Converters
{
public class TextToWidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
var fontSize = double.Parse(parameter as string);
var text = value as string;
return text?.Length * fontSize ?? 0;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
}