This is a migrated thread and some comments may be shown as answers.

Detecting selection of InlineUIContainer

2 Answers 187 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 09 May 2011, 05:55 PM
Hi again,

How would I detect whether the RichTextBox selection contains an InlineUIContainer?

The DocumentSelection classes don't seem to support this out of the box with something like the FlowDocument TextSelection.Contains(TextPointer) call and the InlineUIContainer doesn't have it's own position information (like InlineUIContainer.ContentStart and ContentEnd properties for FlowDocument classes).

It seems slightly strange that you can use a DocumentPosition to insert something in a document but the element itself doesn't retain some of that information for later comparison against the SelectionRange objects to determine what is in the selection.

Could you point me in the right direction to solve/workaround this?

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Ivailo Karamanolev
Telerik team
answered on 11 May 2011, 01:34 PM
Hello Paul,

The element position information is tightly related to the DocumentPosition class. It features several important properties, namely:
  • Overloaded operators - ==, >, <, <=, >=
  • Navigation methods: various methods to move the document position around, including MoveToInline. Also a constructor to create a DocumentPosition from a layout box.
You can use these methods to create two document positions around the InlineUIContainer and determine if both of them are inside one of the selection ranges.
Best wishes,
Ivailo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Paul
Top achievements
Rank 1
answered on 11 May 2011, 02:16 PM
Hi Ivailo,

Thanks for the response - that's exactly what I was looking for. I've marked your post as the answer.
Tags
RichTextBox
Asked by
Paul
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
Paul
Top achievements
Rank 1
Share this question
or