I'm trying to programatically remove a span element from a document like this:
span.Parent.Children.Remove(span);
This works, but it seems to mess with the formatting of the next span in the paragraph.
Has anybody come across this, or know of a workaround?
4 Answers, 1 is accepted
0
Michael
Top achievements
Rank 1
Veteran
answered on 08 Feb 2018, 11:22 PM
PS I'd settle for collapsing the contents of the span so it's invisible and 0 width.
0
Hello Michael,
Could you please try to remove the span using the API of RadDocumentEditor? Usually, removing document elements by directly modifying through the model (their Children collections) is an approach that we do not suggest using as it might lead to unexpected behavior if used after the document is already measured.
In case you are still experiencing the issue, I would like to ask you to share more details about the scenario. Will be of a great help to elaborate more on what the structure of the elements is and how are they styled, so we can reproduce the case on our end and test it.
Regards,
Tanya
Progress Telerik
Could you please try to remove the span using the API of RadDocumentEditor? Usually, removing document elements by directly modifying through the model (their Children collections) is an approach that we do not suggest using as it might lead to unexpected behavior if used after the document is already measured.
In case you are still experiencing the issue, I would like to ask you to share more details about the scenario. Will be of a great help to elaborate more on what the structure of the elements is and how are they styled, so we can reproduce the case on our end and test it.
Regards,
Tanya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.
0
Michael
Top achievements
Rank 1
Veteran
answered on 28 Feb 2018, 07:34 AM
Hi Tanya,
I'm working on an export process that currently works like this:
- User edits a document, clicks export.
- App makes a deep copy of the document.
- Background thread mutates the copy according to business rules. (Including removing some spans/paragraphs)
- Background uses the copy to build a document in another file format.
As such, the document i'm trying to edit here isn't associated with an Editor.
Thanks
0
Hello Michael,
RadDocumentEditor can be used in scenarios without UI and that is one of the main reasons for its addition to the API. All you need to do is to instantiate it with the RadDocument instance you are using in the background thread. Then, you can modify the document using the methods of the editor.
If you are still observing the same issue, I would much appreciate sharing more information on the scenario, so I can test it and try to provide you with a suitable approach to overcome it.
Regards,
Tanya
Progress Telerik
RadDocumentEditor can be used in scenarios without UI and that is one of the main reasons for its addition to the API. All you need to do is to instantiate it with the RadDocument instance you are using in the background thread. Then, you can modify the document using the methods of the editor.
If you are still observing the same issue, I would much appreciate sharing more information on the scenario, so I can test it and try to provide you with a suitable approach to overcome it.
Regards,
Tanya
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which you to write beautiful native mobile apps using a single shared C# codebase.