Inline text box labels with WPF

Posted by Douglas on Stack Overflow See other posts from Stack Overflow or by Douglas
Published on 2010-03-26T23:29:11Z Indexed on 2010/03/26 23:33 UTC
Read the original article Hit count: 226

Filed under:
|
|
|

I'm trying to reproduce the layout of some paper forms in a WPF application. Labels for text boxes are to be "inline" with the content of the text boxes, rather than "outside" like normal Windows forms. So, with an Xxxxxx label:

+-----------------------------+
| Xxxxxx: some text written   |
| in the multiline input.     |
|                             |
| another paragraph continues |
| without indentation.        |
|                             |
|                             |
+-----------------------------+

The Xxxxxx cannot be editable, if the user selects all the content of the text box, the label must remain unselected, I need to be able to style the text colour/formatting of the label separately, when there is no text in the text box, but it has focus, the caret should flash just after the label, and I need the baselines of the text in the text box and the label to line up.

One solution I tried was putting a textblock partially over the input, then using text indent to indent the editable text, though this caused problems with following paragraphs, since they were indented too. I'm not sure how to indent just the first paragraph. It required some fiddling to get the text to line up - a more reliable setup would be ideal.

So, any suggestions on how to set this up?

Thanks

© Stack Overflow or respective owner

Related posts about wpf

Related posts about gui