Formatting Zero Values as Empty String? Formatting Zero Values as Empty String? wpf wpf

Formatting Zero Values as Empty String?


Example IValueConverter

   [ValueConversion(typeof(string), typeof(string))]    public class StringToFeetAndInches : IValueConverter    {        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)        {            string str = value as string;            if (string.IsNullOrEmpty(str)) return str;            str = str.Insert(1, "'");            str = str + "\"";            return str;         }        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)        {            return 0;        }    } <UserControl.Resources><NS:StringToFeetAndInches x:Key="cStringToFeetAndInches"/></UserControl.Resource> <TextBlock Text="{Binding Path=Height, Converter={StaticResource cStringToFeetAndInches}}" />