Masked TextBox with differing sized text - wpf

OK, I admit this is an unusual case! I need a masked TextBox in which groups of different characters are different sizes. The text has to be selectable as a single block for copy / paste / delete purposes.
I'm not sure how I'd go about this in WPF. Any ideas?

You want to change from TextBox to RichTextBox. In a richtextbox, you can control format of parts of the text.

Related

Does WPF Textbox respect Unicode BIDI controls like LRI/RLI?

I need to display English + Hebrew text mixed in a text box. I embed each language with the appropriate RLI/LRI/PDI controls but it seems that it doesn't make any difference. Depending on the content, things end up out of order, like if the BIDI controls are being ignored.
To check that my BIDI controls are placed correctly, I take the same text displayed in the textbox and put it in Clipboard. Pasting it to notepad or word displays the text in the expected order while on the textbox it isn't.
Can someone confirm if WPF textbox should respect these Unicode BIDI controls?
Am I missing any special setting on the textbox so it takes it into consideration?

How to put ellipsis (...) in RichTextBox

I want to put an ellipsis (..) in the rich text box.
In normal TextBlock, TextTrimming="WordEllipsis" has a property that limits the length to allow ellipsis representation, but rich text boxes do not. And it should only be implemented as a rich textbox now. Text blocks are not allowed.
I'd like to trim by two or three lines and add an ellipsis (..) option. Is there any good way?
I want to show you how I'm using RichTextBox, but the reputation is low.
You don't
The ellipsis concept is, as stated by grek40, something that only works when displaying text.
As an example, say the ellipsis is displayed, and the user tries to partially select some text in your RichTextBox, including the ellipsis, what would the selected result be? You can't tell.
Maybe
Since an ellipsis is usually a replacement for a Scrollbar, hiding text instead of allowing you to access it by scrolling, you might be able to fake it by using a WPF Style.
Create a Style that displays an icon/picture of an ellipsis (placement is up to you) whenever the Scrollbar visibility trigger is triggered. You would need to disable the Scrollbar once the ellipsis is visible.
This obviously requires more effort than simply setting a property, and it can easily become a User Experience nightmare if not carefully implemented, so be warned.
Note: Another comment (by Walt Ritscher) linked to a similar question, the solution there is similar to this one.
Alternative Maybe
Another faked ellipsis could be achieved by using two different RichTextBox controls.
The first RichTextBox would have set ReadOnly to true. Trim your text to a maximum allowed length, and append an ellipsis and display it inside this first RichTextBox.
When the user need to edit the text hide the first RichTextBox and display a second RichTextBox that contains your entire text.

Getting Clear Text Index of WPF RichTextBox Selection

I need to be able to highlight multiple blocks of plain text given a start index and length inside an editable control. Now I know that it's not possible to do this with a regular TextBox so am looking at using a RichTextBox instead. The problem I'm having is that I can't seem to find what the clear text index would be from the selected text inside a RichTextBox.
I can add a background colour easily enough to a selection, but I need to be able to get at the clear text index of where the selection is and the length of the selection (which seems easy enough) as this is what is getting stored in a database.
Any help is greatly appreciated - this is driving me nuts!

.NET WinForms Localization - How to make control position based on length of text

I am working on localizing a WinForms application through satellite assemblies. The problem I am facing is that when I switch to some other language such as Japanese from English, the labels overlap (or go behind) the combo boxes because of the change in text. The change in text causes Label width to increase making them jump over to other controls.
Is there a way (maybe through Anchoring) to overcome this so that the combo boxes decrease their width automatically to compensate for the Label size increase? Something like anchoring WRT a control instead of a Form.
UPDATE
OK. I think I've found a solution to this one. The Form has a Language property which is used to set language specific properties for a Form. If I change it to Japanese and make changes to Form layout and Control positions then these language specific items are stored in a new .RESX file for each Form. The Satellite assemblies will still be used to provide the localized strings but these RESX files will resize the Form elements accordingly. Is this the right way?
The Form has a Language property which is used to set language specific properties for a Form. If I change it to Japanese and make changes to Form layout and Control positions then these language specific items are stored in a new .RESX file for each Form. The Satellite assemblies will still be used to provide the localized strings but these RESX files will resize the Form elements accordingly.
I don't know anything that can resolve satisfactorily your problem.
There is the property AutoEllipsis=True (with AutoSize=False) that can alleviate the situation.
If set to True this property insert three dot to the right of the label when the text exceed the label dimensions. Positioning the mouse over the label will dispaly a tooltip with the full text.

Selectable text in wpf

I am trying to render a WPF window that has lots of labels, textboxes, textblocks which are binding to data.
I want to be able to select by mouse all the data or part of the data on the window.
Is there a simple way in WPF to do that?
Should I use page instead of window?
Thanks
It is not possible to select text across multiple TextBox, Labels and TextBlocks in WPF.
Each control will hold selection specifically to itself so you must use another approach that will enable you to select the text.
I can think of one rudimentary way to achieve this is to have a very small button beside each TextBox,TextBlock, etc. that you wish to select and this button will perform a string concatenation of the associated text to the clipboard.
The result is that you have all the strings you wish to select in your clipboard ready to paste to wherever you like.
Good luck.

Resources