I know I can apply FormatString to format Column Display in XAML. But I want to format Columns dynamically (depending on some conditions). How can I implement it in Code Behind? Thanks.
Hi, xamluser,
Thanks for your suggestion. If I understand it correctly, I can apply ValueConverter to format different columns at same time. However, my issue is that I need to format the SAME column dynamically. How to implement it? Thanks.
You can use valueConverter
It would look like
public class DecimalEditorValueConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return String.Format(culture, "{0:N2}", value); }
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) { return value; } }
and in xaml use it with your control as
ValueConverter="{StaticResource DecimalEditorValueConverter }"