I have a grid bound to a data source and I wish to use a converter to change some of the values in the grid. I've used a converter before to change some of the other properties such as font color and they worked fine, but when it comes to changing content there's an issue.
I've debugged the code and the converter is getting correctly called and is return the correct values, but the raw values are still displayed in the grid. My converter is just returning strings, is there a reason why it's unable to render them?
Thanks
<DataPresenter:Field Name="myField" Width="Auto"> <DataPresenter:Field.Settings> <DataPresenter:FieldSettings> <DataPresenter:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type DataPresenter:CellValuePresenter}" > <Setter Property="" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content, Converter={StaticResource myConverter}}" /> </Style> </DataPresenter:FieldSettings.CellValuePresenterStyle> </DataPresenter:FieldSettings> </DataPresenter:Field.Settings> </DataPresenter:Field>
Actually that's not the same thing. You were providing a CellValuePresenter Style and trying to use a converter there in the element. What Alex is referring to is setting the Converter property of the Field.
that's what I was initially doing in post 1...no luck though
Hello,
Sorry for the late response. You should not be binding the Converter to its content, as this will not work.
I got a hint from the development team, that actually the Converter property of the Field will do exactly what you are looking for - change the displayed value and not change the underlying value, so you can try that instead of the ValueToDisplayTextConverter.
I did this
<DataPresenter:Field Name="myfield" Width="Auto"> <DataPresenter:Field.Settings> <DataPresenter:FieldSettings> <DataPresenter:FieldSettings.EditorStyle> <Style TargetType="{x:Type Editors:XamTextEditor}" > <Setter Property="ValueToDisplayTextConverter" Value="{Binding RelativeSource={RelativeSource Self}, Path=Content, Converter={StaticResource myConverter}}" /> </Style> </DataPresenter:FieldSettings.EditorStyle> </DataPresenter:FieldSettings> </DataPresenter:Field.Settings> </DataPresenter:Field>
but the converter is never called, does anything look wrong?
thanks
Yes, in this case you I think you could use the ValueToDisplayTextConverter property of the underlying editor (for example XamTextEditor). You have to create a style for the editor for that field and apply it at the Fiedl's Settings EditorStyle property.