add readonly password reveal

This commit is contained in:
TheXamlGuy
2024-07-06 17:01:50 +01:00
parent 543ea01e62
commit 02c7c03251
2 changed files with 22 additions and 1 deletions
@@ -0,0 +1,21 @@
using Avalonia.Data.Converters;
using Avalonia.Markup.Xaml;
using System.Globalization;
namespace Toolkit.UI.Avalonia;
public class BooleanToPasswordCharConverter :
MarkupExtension,
IValueConverter
{
public override object ProvideValue(IServiceProvider serviceProvider) =>
this;
public char PasswordChar { get; set; }
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
value is bool boolValue ? boolValue ? '\0' : PasswordChar : (object)PasswordChar;
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
throw new NotImplementedException();
}