Welcome to the Xceed Community Sign in | Join | Help
Community Search  

RTF in Xceed DataGrid for WPF

Sort Posts: Previous Next
  •  05-01-2008, 3:28 AM Post no. 11891

    RTF in Xceed DataGrid for WPF

    Hi guys,

    I need to make the certain column in the grid to be rich text formatted column. It means that I have table with text field. Values of the field is RTF text. So I want to get the text formatted in the grid.

    The only way to do that as I have understood is to set to CellContentTemplate column property template with RichTextBox:

     

    DataTemplate template = new DataTemplate( typeof( RichTextBox ) );

    template.VisualTree = control;

    _grid.Columns[ 0 ].CellContentTemplate = template;

     

    But I have 2 problems here:

    1. How can I customize the RichTextBox properties before I give it to CellContetTemplate? (for ex. make its border style none)

    2. How can make the RichTextBox in the grid cell to show cell text? As I understand I should bind the Content of RichTextBox to cell text...

    Would anybody provide me a code sample how to do it?

     Thanks a lot

  •  05-01-2008, 10:08 AM Post no. 11897 in reply to 11891

    Re: RTF in Xceed DataGrid for WPF

    You need to use a CellEditorBinding in order to bind the content of the RichTextBox to the cell's; however, if you want to use the WPF RichTextBox, you might be in for a surprise as it is not like the WinForms one and can't be easily bound to.

    For example, in the WPF RTB, there is no Text property to which you can bind but rather a Document property, which exposes a FlowDocument an that is not bindable. You would need to create a "BindableFlowDocument" as demonstrated here and then bind to that property using the CellEditorBinding.

     


    Technical Writer - Xceed Software

    Of all the things I've lost, I miss my mind the most. - Mark Twain
View as RSS news feed in XML
Contact | Site Map | Reviews | Legal Terms of Use | Trademarks | Privacy Statement Copyright 2008 Xceed Software Inc.