using System;
using System.Collections.Generic;
using System.Text;
using Windows.UI.Xaml.Data;

namespace BoxOfficeDashboard.Converters
{
    public class DoubleFormatter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, string language)
        {
            double d = (double)value;
            return d.ToString(parameter.ToString());
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            string strValue = value as string;
            double resultValue;
            if (double.TryParse(strValue, out resultValue))
            {
                return resultValue;
            }
            return double.NaN;
        }
    }
}
