0
votes

This is the scenario:

I have a telerik gridview on my page, this is bound to a PagedCollectionView with items of class "GekoppeldeOntvangstRegel",

this class implements INotifyPropertyChanged

Several columns have a CellTemplate with a TextBlock bound to an object of this class, like this:

 <TextBlock Text="{Binding ConverterParameter='aantal', Converter={StaticResource GekoppeldeRegelDecimalFormatConverter}, NotifyOnValidationError=True, ValidatesOnDataErrors=True, ValidatesOnExceptions=True, ValidatesOnNotifyDataErrors=True}" HorizontalAlignment="Right" ToolTipService.ToolTip="{Binding ConverterParameter='aantal', Converter={StaticResource GekoppeldeRegelToolTipDecimalFormatConverter}}" />

This converter converts the "Aantal" property to a string with a specific number of decimals. When I update the "Aantal" property from code with the OnPropertyChanged("Aantal") of course the binding isn't updated (since the textblock is bound to the entire object, not the property) so the old value is still visible.

How can I refresh the column contents from my viewmodel or object when the property changes?

When I bind directly to the "Aantal" property everything works perfectly (besides the converter not being applied, which is necessary)

1
why don't you bind the text to the property itself? - Peter Porfy
the object "GekoppeldeOntvangstRegel" is provided by entity framework and has several navigation properties to other objects. These objects are required to determine the number of decimals that need to be displayed in the column. This is done in the converter so binding to the property itself isn't enough. Sadly the converter can't have a converter parameter with a binding, only a static value. - Thomas

1 Answers

0
votes

As a workaround I now have created several extra properties on the "GekoppeldeOntvangstRegel" class.

These properties call the converter and return the right value with the right number of decimals. On these properties raising OnPropertyChanged does work to refresh the bindings.

I'm not really happy with this solution but it works for now.