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

Drop within a multi-line TextBox

1 Answer 83 Views
DragAndDrop
This is a migrated thread and some comments may be shown as answers.
GEB
Top achievements
Rank 1
GEB asked on 15 Oct 2009, 10:50 PM
I am successfully dragging a string from a ListBox to a multi-line TextBox.  However, as the user is dragging into the TextBox, I'd like to show the insertion point as the user drags across the TextBox, allowing the user to drop to an insertion point of their choice.  Is there an example, or any ideas as to how this can be accomplished?

The way I'm dropping this within the TextBox today is to drop into the TextBox's current insertion point (TextBox.SelectionStart).  But, this does not allow the user to physically see where the string will be dropped as it is being dragged, and it does not allow the user to "move" the insertion point during the drag operation.  Any ideas would be appreciated.  I would think this is something that several applications could use.


1 Answer, 1 is accepted

Sort by
0
Miroslav
Telerik team
answered on 20 Oct 2009, 07:36 AM
Hi GEB,

Unfortunately the Silverlight TextBox does have a very limited API and you cannot retrieve the text offset index based on the mouse position.

I believe that there may be a way to estimate the current row in the TextBox if the text in the text box is not wrapped. You can inherit the text box and get its scroll viewer. Then you can use its ExtentHeight to get the total height of the text and then do some calculation to find the text row height and use the mouse position to display an overlay marker and then insert something there. This though sounds like a hacky solution and I cannot think of a workaround if the text is wrapped.

Best wishes,
Miroslav
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
DragAndDrop
Asked by
GEB
Top achievements
Rank 1
Answers by
Miroslav
Telerik team
Share this question
or