<syncfusion:GridNumericColumn MappingName="UnitPrice" NumberDecimalDigits="2" >
<syncfusion:GridNumericColumn.DisplayBinding>
<Binding Path="UnitPrice">
<Binding.Converter>
<local:NumberRounOffConverter/>
</Binding.Converter>
</Binding>
</syncfusion:GridNumericColumn.DisplayBinding>
</syncfusion:GridNumericColumn> |
public class NumberRounOffConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return string.Empty;
return Math.Round((double)(value));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |
this.sfgrid.AutoGeneratingColumn += Sfgrid_AutoGeneratingColumn;
private void Sfgrid_AutoGeneratingColumn(object sender, Syncfusion.UI.Xaml.Grid.AutoGeneratingColumnArgs e)
{
if(e.Column.MappingName == "UnitPrice")
{
e.Column.DisplayBinding = new Binding("UnitPrice")
{
Converter = new NumberRounOffConverter()
};
}
} |
public class NumberRounOffConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return string.Empty;
return Math.Round((double)(value));
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
} |