Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Text selection across TextBoxes

Tags:

c#

.net

wpf

I am currently attempting to write a Script Writer along the lines of FinalDraft and Adobe Story. I am using WPF and .NET 4.0.

Instead of using a giant textbox in which I handle the user's inputs to determine the next course of action, I decided to try using multiple textboxes which are dynamically created and positioned on top of a canvas depending on the users action.

The problem I am running across is that I'm unable to select text from different textboxes by simply dragging and holding the left mouse button. I realize that this feature is not built-in, and so I tried to use variouse mouse events to achieve this functionality with code.

Unfortunately, the events that I would need are not fired if a particular textbox has the mouse's focus.

How would you approach this problem ? Is text selection across TextBoxes even possible in WPF ?

If not, what alternative would I have other than use a single textbox ?

like image 221
Hussein Khalil Avatar asked Jan 20 '26 14:01

Hussein Khalil


1 Answers

Did you try overriding the event-bubbling by attaching to mouse events using AddHandler while specifying handledEventsToo to true?

like image 85
Kolky Avatar answered Jan 22 '26 03:01

Kolky