Bug Report Q404976
Visible to All Users

Data Binding issues while using RtfToContentConverter for the RichEditControl used in Data Template

created 13 years ago

Q227266 is the issue first reported and replied to - to my colleague Stephen Mills. (I don't see a way to reply to the original and/or see colleague issues anymore???)

We implemented the converter as you directed in the above referenced issue. (see below xaml snippet)

The text is being correctly converted to rtf and back.

Our problem is that when a new row is added or a row is edited, multiple rows are marked as "changed" in the datacontext.

When the rtf converter is removed from the xaml, the only record marked as changed is/are record(s) that have been added or edited, i.e. something with the converter is causing other rows, but not all rows, in the grid to be marked "changed" (haschanges).

Are you aware of this and/or do you have a work around?

<dxg:GridColumn Header="Contract Note"
MinWidth="200"
AllowEditing="True"
Visibility="Visible"
FieldName="ContractNote">
<dxg:GridColumn.CellTemplate>
<DataTemplate>
<dxr:RichEditControl HorizontalScrollBarVisibility="Collapsed"
Content="{Binding RowData.Row.ContractNote, Converter={StaticResource RtfToContentConverter}, Mode=TwoWay}"
ActiveViewType="Simple"
Height="75">
</dxr:RichEditControl>
</DataTemplate>
</dxg:GridColumn.CellTemplate>
</dxg:GridColumn>

Answers approved by DevExpress Support

created 11 years ago (modified 11 years ago)

We have fixed the issue described in this ticket and will include the fix in our next maintenance update. To apply this solution before the official update, request a hotfix by clicking the corresponding link for product versions you require.

Note: Hotfixes may be unavailable for beta versions and updates that are about to be released.

Additional information:

We have implemented the RichEditControl.UseDeferredDataBindingNotifications property. To apply the fix, it is necessary to set this property to False. You can do this from XAML or code behind.

    Other Answers

    created 13 years ago (modified 12 years ago)

    Hi,
    Thank you for your question. RtfToContentConverter converts the original value into an internal RTF object. The ConvertBack result may differ from the original value, because the ConvertBack method is executed when the grid content is being changed (sorting, adding or removing rows, etc.), some rows in DataContext may be changed. There is no workaround for this problem.
    Updated by Stan (DevExpress Support):
    The root cause of the problem here is that there is no easy way to determine whether or not RichTextEdit's content modification has been performed through the binding mechanism. Due to the performance reasons RichEdit does not perform comparison of a newly assigned value with its internal structure. This causes each Content modification to reconstruct the internal document, which, in its turn, causes the resulting document to be passed back to the content.
    We will do our best to bypass this behavior internally, but I cannot give you any guarantee here. At the moment, I can suggest you separate logic of displaying and editing data using different templates. Take a look at the attached sample, which demonstrates this approach.

      Show previous comments (1)
      Stan (DevExpress Support) 13 years ago

        Hi Liz,
        Before all I should apologize for an incomplete answer. Our engineer has mistakenly marked this ticket as solved. I'm going to reset this flag and update our answer.

          Apology accepted, thank you.
          Your approach is the workaround we implemented (successfully)as our own workaround. I haven't reviewed your sample, yet. We are using a childwindow (dialog) for add and edit. That happens to be consistent with other areas of our application where complex adds and edits are handled in a dialog vs direct editing in the grid.

          Stan (DevExpress Support) 13 years ago

            Hi Liz,
            Thank you for your feedback. Nevertheless, I strongly recommend you avoid using two-way binding or utilize DisplayTemplate as demonstrated in the previously attached example. This way you will prevent data from being unexpectedly modified.

            Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

            Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.