-2

Can anyone please provide me some pointers or direct me to a sample Converter for WPF that will take a number like 100 and convert it to 10²?

user1869870
  • 453
  • 2
  • 8
  • 19
  • 1
    Do you want your numbers to be expressed in [scientific notation](https://en.wikipedia.org/wiki/Scientific_notation)? How would you represent, say, 9529? – Douglas Jan 20 '14 at 22:15
  • [IValueConverter](http://msdn.microsoft.com/en-us/library/system.windows.data.ivalueconverter(v=vs.110).aspx) is *really* easy to work with (especially if you only need this to be one-way). Why don't you try it and ask a *specific* question if there's something you are stuck on. – Matt Burland Jan 20 '14 at 22:17
  • 2
    I think you're looking for `log10(100)`, i.e. `System.Math.Log(100, 10)` – Mike Christensen Jan 20 '14 at 22:17

1 Answers1

1

Example WPF converter:

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();
    }
}

I'm not sure how exactly you want to convert the number, but you can find some examples here: Double to string conversion without scientific notation

Community
  • 1
  • 1
Fayilt
  • 1,042
  • 7
  • 16