0

Is is possible to embedd a TextBox in another TextBox. It does not have to be a TextBox, any editable text-component will suffice. I tried it with TextBox and got compiler errors.

Reasoning: I want to create some kind of source code editor. I want that string literals in my source code are allowed to contain all kinds of special characters like ",'\ and so on. To achieve this, all string literals should be encapsulated in separate textboxes within the source code to separate them from the other text.

Saving and loading of the source is done using xml with all special chars converted to entities, so my only problem is the proper editing. I do not want to put the user off with escaping sequences and so on.

1 Answer 1

1

One option for this would be to use a FlowDocument instead of a TextBox. This would let you embed as many TextBlock elements with TextBox controls, and have it "flow" naturally in a document.

Sign up to request clarification or add additional context in comments.

2 Comments

is it "lightweight" enough for me? I will have lots of them since I want to implement every code line as separate control
I'd recommend a singe FlowDocument for your whole file, and allow it to "flow" through multiple lines, replacing sections with controls as needed. If you're doing each line as a separate control, then you'll probably want to use a WrapPanel, with inter-mixed TextBlock and TextBox elements. See: msdn.microsoft.com/en-us/library/ms754037.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.