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
630
xamDataGrid and richtextbox field
posted

Hi

I was hoping someone could give me an example of how to incorporate a richtextbox control as a field in xamDataGrid. The grid wont be used in edit mode. I have heard of cellpresenterstyle but not seen example yet?

I just need to show some text, and I think the generic field is having problems because of the various formatting of the text (line breaks etc)

Any help would be greatly appreciated.

Thanks

  • 69686
    Verified Answer
    posted

    Hello,

    The RichTextBox element cannot directly bind to the content of the Cell. The Cell's Value is a string or integer or some other type, however the RichTextBox's Content should be of Document Type (RichTextBox). You would have to convert the value of the Cell and provide it to the RichTextBox is the format that it requires. 

    The style for the CellValuePresenter that you are looking for should look something like this:

     

     <Style TargetType="{x:Type igDP:CellValuePresenter}">

                <Setter Property="Template">

                    <Setter.Value>

                        <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">

                            <RichTextBox >

                                <FlowDocument >                   

                                </FlowDocument>

                            </RichTextBox>

                        </ControlTemplate>

                    </Setter.Value>

                </Setter>

            </Style>