using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Globalization; namespace WpfTestSvgSample { /// /// Used in MainWindow.xaml to converts a scale value to a percentage. /// It is used to display the 50%, 100%, etc that appears underneath the zoom and pan control. /// public class ScaleToPercentConverter : IValueConverter { /// /// Convert a fraction to a percentage. /// public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { // Round to an integer value whilst converting. return (double)(int)((double)value * 100.0); } /// /// Convert a percentage back to a fraction. /// public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { return (double)value / 100.0; } } }