System.FormatException: ‘位置“0”上遇到异常的令牌
Path绑定Data需要将String转成Geometry,
public class DataStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string s = (value as string).ToString(System.Globalization.CultureInfo.InvariantCulture);
if (s == null)
return null;
var geometry = Geometry.Parse(s);
return geometry;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//throw new NotImplementedException();
return null;
}
}
当出现【System.FormatException: ‘位置“0”上遇到异常的令牌】“,先检查String是否有错误,如果确认问题,那么问题出在存储String的文本文件上,将存储String的文本文件用记事本打开,另存为ANSI既可以!