28 lines
655 B
C#
28 lines
655 B
C#
using System;
|
|
using Toolkit.Foundation;
|
|
|
|
namespace Toolkit.UI.WinUI;
|
|
|
|
public class ValidationToBoolConverter :
|
|
ValueConverter<IReadOnlyIndexDictionary<string, string>, bool>
|
|
{
|
|
public string? Property { get; set; }
|
|
|
|
public bool TrueValue { get; set; } = true;
|
|
|
|
public bool FalseValue { get; set; } = false;
|
|
|
|
protected override bool ConvertTo(IReadOnlyIndexDictionary<string, string> value,
|
|
Type? targetType,
|
|
object? parameter,
|
|
string? language)
|
|
{
|
|
if (Property is { Length: > 0 } && value.ContainsKey(Property))
|
|
{
|
|
return TrueValue;
|
|
}
|
|
|
|
return FalseValue;
|
|
}
|
|
}
|