added AppendTextConverter

This commit is contained in:
John Colvin committed 2019-08-27 13:10:37 -04:00
1 parent 8ef97d012a
commit d9bb667351
1 file changed
+22
@@ -0,0 +1,22 @@
using System;
using System.Globalization;
using System.Text;
using System.Windows.Data;
namespace mbts.ui.converters {
class AppendTextConverter : IValueConverter {
public string Prefix { get; set; }
public string Suffix { get; set; }
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
var sb = new StringBuilder(value?.ToString());
// don't need to check for null (Insert/Append support it)
sb.Insert(0, Prefix);
sb.Append(Suffix);
return sb.ToString();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) =>
throw new NotImplementedException();
}
}