using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace FLY.ControlLibrary.Converter
{
    class PercentConverter:IValueConverter
    {
        #region IValueConverter 成员

        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double percent = (double)value;
            return (percent * 100).ToString("F1");
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            double percent = 0;
            if (double.TryParse(value as string, out percent))
            {
                return percent / 100.0;
            }
            else
            {
                return 0;
            }
        }

        #endregion
    }
}