I am using a pretty long StringFormat for my bound tooltip and am currenly trying to make it multiline in XAML.
While I was able to make literal ToolTip multiline using
for line breaks I am unable to get it to work with StringFormat.
I am trying to get following code to give me a tooltip with line break:
ToolTipService.Tooltip= {Binding Property,StringFormat='FORMAT WITH LINE BREAK {0}'}
Actually I got correct answer here:
official silverlight forums link
We can use
for line break.
or :
<TextBox Text="{Binding Path=a,
StringFormat='First Line \{0\}
Second Line'}" />
Difference is pretty big.. This one works.
In string format output, have you tried using \r instead to insert carriage returns?
The only reason these encodings exist is to allow special character values to be placed in XML/Xaml.
The
is just an encoding for hex character A = decimal 10 = \r (carriage return).
Another one of interest is
which is character D = decimal 13 = \n (newline).
Note Hex encoding normally requires pairs of digits so
was the actual error.
Related
I am trying to add a special character (specifically the ndash) to a Model field's help_text. I'm using it in the Form output so I tried what seemed intuitive for the HTML:
help_text='2 – 30 characters'
Then I tried:
help_text='2 \2013 30 characters'
Still no luck. Thoughts?
django escapes all html by default. try wrapping your string in mark_safe
You almost had it on your second try. First you need to declare the string as Unicode by prefacing it with a u. Second, you wrote the codepoint wrong. It needs a preface as well; like \u.
help_text=u'2\u201330 characters'
Now it will work and has the added benefit of not polluting the string with HTML character entities. Remember that field value could be used elsewhere, not just in the Form display output. This tip is universal for using Unicode characters in Python.
Further reading:
Unicode literals in Python, which mentions other codepoint prefaces (\x and \U)
PEP263 has simple instructions for using actual raw Unicode characters in a source file.
I would like display, in a textbox, the spaces and the carriage return in order to show the user the exact test formatting, ie using a central point for spaces and an arrow for CRLF. Any idea ?
Eah, it's really hard! But you can replace spaces with some printable symblos for display purposes only. But carriage you shouldn't replace, just add new Symbols.
And before text usage, before writing to file for example, just convert all symbols back to spaces.
This solutiond of course, is not universal and complete.
We're currently using a custom format string: "#,###.##"
In our DevExpress control in the following way:
"Settings:TextEditSettings MaskType="Numeric" DisplayFormat="#,###.00;;#" Mask="#,###.##"/"
Imagine the input to this is the double "20.000".
We'd like this to be "20.00" in display mode, and "20" in edit mode (i.e. what the Mask is trying to specify). We find that this almost works, but there we get "20." in edit mode. Can anyone advise on a format string that does not have the trailing "." when the number is whole?
Thanks.
For display mode use "0#.0#" and in Edit mode use "0#"
[Edit]: Since your showing commas for display, use "0#,###.0#"
I've got a FlowDocument generating a document for a client, and it's getting a line break that they don't like. Is there any way to mark a section of text that it should avoid line breaks? Something like this:
<Paragraph>Here is a paragraph where there should be <span NoLineBreak=True>no line break</span> in a certain part.</Paragraph>
Obviously, a Span doesn't have a NoLineBreak property, but I'm wondering if there's some equivilant functionality available, or if someone can get me started on a way of implementing a SpanWithNoLineBreak class or RunWithNoLineBreak class?
UPDATE
Actually, one issue I'm having is with a percent sign, where there isn't even a space:
<Paragraph>When I print and ½% I want the one-half and '%' symbols to not line break between them.</Paragraph>
The & #x00BD; is the unicode for a ½ symbol. I'm getting a line wrap between the 1/2 and the % even though there's no space between them.
The Unicode character "Word Joiner" (U+2060) is intended for just this purpose. It "does not normally produce any space but prohibits a line break on either side of it" (Wikipedia). You place it between U+00BD and '%' to prevent a line break between them.
Unfortunately, WPF (or perhaps the typical fonts supplied with Windows) don't support it properly, and instead render it as a square box. As an alternative, you could use U+FEFF; the use of this character as a zero-width non-breaking space is now deprecated (it's reserved for use as a byte-order mark), but it worked as a line-break-preventer for me.
Finally, there are some other characters that can also be used for this purpose: U+202F (narrow no-break space) also prevents breaking, but also renders as a very thin space. U+00A0 (no-break space) prevents breaking and displays as a normal space.
Try replacing the spaces with non-breaking spaces.
EDIT: Well there's always the backup plan of just putting in TextBlocks in your FlowDocument with TextWrapping=NoWrap, but I'd try to find a better way...
I've got a WinForms RichTextBox in my application. When I enter the Chinese text "蜜蜜蜜蜜", the control uses the following RTF:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fmodern\fprq6\fcharset134 SimSun;}{\f1\fnil\fcharset0 Microsoft Sans Serif;}}
\viewkind4\uc1\pard\f0\fs17\'c3\'db\'c3\'db\'c3\'db\'c3\'db\f1\par
}
The test string is the same character four times. It's Unicode value is 34588 (0x871C). So how is it that the character is being stored as "\'c3\'db" in the RTF? What kind of encoding is that?
RTF is old, older than Job and considerably predates Unicode. I think it using code page 936, a double-byte character set for Simplified Chinese. Your snippet shows it using c3db for the character, it matches the glyph shown in this table.