Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
RTF in XamDataGrid

I would like to display a formatted RTF text ex. {\rtf1 \b Hello \b0 World} in a XamDataGrid cell. I have a collection bound to the grid. The collection item looks more or less like that:

public class GridItem
    public string RtfText {get; set; }

If possible, I would like to edit the RTF directly in the cell.

A little sample would be perfect.

  • 520
    Verified Answer
    Offline posted


    Displaying a RTF editor in a XamDataGrid cell can be achieved by styling the CellValuePresenter of the cells in the field you want to have the editor positioned.

    <Style TargetType="{x:Type igDP:CellValuePresenter}" x:Key="richTextBoxField">
                        <Setter Property="Template">
                                <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
                                    <RichTextBox x:Name="rtb">
                                                <Run Text="{Binding RelativeSource={RelativeSource TemplatedParent}, 
                                                    Converter={StaticResource stringConverter}}"/>

    As i do not know what datasource will be bound to this grid, I have not completed a full sample, but in case you will be passing a collection of strings, you can either use a converter to load the text, or alternatively, you can make your own RichTextBox and create a Text property of it, which will be interacting with the datatype you will be passing from your DataSource.

    Should you need further information, please let me know.

    Tihomir Tonev
    Associate Software Developer