Creating a Fill-In-The-Blank String

njsokalski

Well-known member
Joined
Mar 16, 2011
Messages
102
Programming Experience
5-10
I am making an app in which I need to display the following two strings:

1. A string that contains pretty much any character(s)
2. A string that is the same as the first with all letters (not other characters) replaced with some character representing a blank space

The first string is entered by the user, and the second string is generated. Generating the string is no problem, my problem(s) come into play when displaying the strings. I want both strings to be displayed with all letters the same width so that both strings wrap at the same points and are the same size. Using a fixed-width font would obviously achieve this, but there is one problem if I use a fixed-width font as the solution to the problem. The character I chose to represent a blank space is █. Unfortunately, this character takes up the full width of a character, so when placed side by side you just have one big rectangle, so the user cannot tell how many characters are in the word. If I place a non-breaking space of a very small font size between them, it looks good, but does not match the size of the first string. The TextBlock does not allow you to specify a background color, so I cannot use that to solve my problem, so the only thing I could think of was to create every character in it's own TextBlock wrapped in another element that specifies a background color and do all the calculations and layout programmatically. Does anybody have any ideas on how to do what I want? Thanks.
 
Top Bottom