You can write a converter to be referenced in the binding. For instance:
public class RoundMyNumberConverter : IValueConverter
{
public object ConvertNumber(object value, Type targetType, object paramater, CultureInfo culture)
{
double result = 0;
if (value != null && (double.TryParse(value.toString(), out result)))
return Math.Round(result,1);
else
return value;
}
public object ConvertBack(object value, Type targetType, object paramater, CultureInfo culture)
{
return value;
}
}
Note: The Math.Round(result, 1<- this is how many places you want after the decimal) so the converter will take in the binding value, run it through the converter and then display the value created.
Then you just reference this inside the xaml as a converter.
Note: Remember to reference your project and assembly if it is outside your current project like:
xmlns:cnvrtr="clr-namespace:MyConverterProject;assembly=MyConverterProject
Also you need to list it as a resource inside your UserControl or Grid?
<Grid>
<Grid.Resources>
<cnvrtr:RoundMyNumberConverter x:key="myConverter"/>
</Grid.Resources>
<TextBlock Grid.Row="5" Text="{Binding SelChem.Lel, Converter={StaticResource myConverter}}"/>
</Grid>
Let me know if you have anymore questions!