WPF - 提升到 - 转换器的力量

时间:2014-01-20 22:12:37

标签: c# wpf

任何人都可以向我提供一些指示或指导我使用转换为WPF的示例转换为100,并将其转换为10²?

1 个答案:

答案 0 :(得分:1)

示例WPF转换器:

public class NumberConverter : IValueConverter
{

    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        //do you conversion here - "value" is the parameter you need to convert and return
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        //you can optionally implement the conversion back (from scientific value to integer)
        throw new NotImplementedException();
    }
}

我不确定你想要如何转换数字,但你可以在这里找到一些例子: Double to string conversion without scientific notation