You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
737 B
22 lines
737 B
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace MultiTerm.Wpf.ValueConverters;
|
|
|
|
public class IntToStringConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
// guard type
|
|
if(value is not int integerVal) { throw new ArgumentException("Can only convert from integer value"); }
|
|
return integerVal.ToString();
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
// guard type
|
|
if (value is not string stringVal) { throw new ArgumentException("Can only convert from string value"); }
|
|
return int.Parse(stringVal);
|
|
}
|
|
}
|
|
|