// (c) Copyright Microsoft Corporation. // This source is subject to the Microsoft Public License (Ms-PL). // Please see http://go.microsoft.com/fwlink/?LinkID=131993 for details. // All other rights reserved. using System; using System.Globalization; using System.Windows.Data; namespace System.Windows.Controls.DataVisualization { /// /// Converts a value to a string using a format string. /// public class StringFormatConverter : IValueConverter { /// /// Converts a value to a string by formatting it. /// /// The value to convert. /// The target type of the conversion. /// The format string. /// The culture to use for conversion. /// The formatted string. public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value == null) { return string.Empty; } return string.Format(CultureInfo.CurrentCulture, (parameter as string) ?? "{0}", value); } /// /// Converts a value from a string to a target type. /// /// The value to convert to a string. /// The target type of the conversion. /// A parameter used during the conversion /// process. /// The culture to use for the conversion. /// The converted object. public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { throw new NotSupportedException(); } } }