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

Inserting InlineUIContainer as Cursor Location

1 Answer 197 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Neil
Top achievements
Rank 1
Neil asked on 12 May 2015, 03:18 PM

Hi,

I am looking to insert an InlineUIContainer by drag/drop of something into the RichTextBox but following dropping of the element, unless it is simple text being inserted I am struggling to work out how to insert an InlineUIContainer at the current cursor location.

 I have managed to insert the control but only to the end of the document.

 A code snippet below might help but errors not at point of insert but when it is trying to update the screen next... The code is taken from the drop handler event.

 

                    Dim point = args.GetPosition(richTextBox)
                    Dim pos = richTextBox.ActiveEditorPresenter.GetDocumentPositionFromViewPoint(point)

                    Dim container As New InlineUIContainer()
                    container.UiElement = New CheckBox() With {.Content = "Testing"}
                    container.Height = 25
                    container.Width = 70
                    ctype(pos.GetCurrentInline().Parent,Paragraph).Inlines.Add(container)

Kind regards,

 

Neil

 

1 Answer, 1 is accepted

Sort by
0
Petya
Telerik team
answered on 15 May 2015, 11:58 AM
Hi Neil,

Are you utilizing the DragDropManager from the WPF suite for this scenario?

We actually have a very similar example in our SDK repository called Drag and drop in editor. It demonstrates insertion of text on drop, but the approach to insert an InlineUIContainer should be very similar.

For your convenience I'm attaching a sample showing the exact scenario. I hope you'll find it useful.

Regards,
Petya
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
RichTextBox
Asked by
Neil
Top achievements
Rank 1
Answers by
Petya
Telerik team
Share this question
or