0

When I have TextBlock. Run Text = "(" Run Text={Binding IncomeLoss} Run Text=")" in a Page it comes out looking ok, but when I have the same thing inside a ControlTemplate that I apply to a class that derives from Control, there is extra space after each character like "( 100 ) ".

I read that ControlTemplate is a barrier to style inheritance, but how do I guess what exactly style parameter is the one missing that is usually inherited by the Textblock on a Page?

Andyz Smith
  • 698
  • 5
  • 20

1 Answers1

2

Make sure that you have put all Run elements on the same line in the ControlTemplate.

There is a difference in output between this:

<TextBlock><Run Text = "(" /><Run Text="{Binding IncomeLoss}"/><Run Text=")"/></TextBlock>

...and this:

<TextBlock>
    <Run Text = "(" />
    <Run Text="{Binding IncomeLoss}"/>
    <Run Text=")"/>
</TextBlock>

If this doesn't work you should provide a minimal, complete, and verifiable example of your issue: https://stackoverflow.com/help/mcve

Community
  • 1
  • 1
mm8
  • 163,881
  • 10
  • 57
  • 88
  • That's it. If you could elaborate, briefly, on a why this is exactly, and ... a good way to keep my markup organized without a 120 column 600 DPI display and 8-power reading glasses. – Andyz Smith Feb 07 '17 at 21:25
  • 1
    Whitespace characters (space, linefeed, tab) are converted into spaces: http://stackoverflow.com/questions/11090084/how-to-get-rid-of-whitespace-between-runs-in-textblock – mm8 Feb 07 '17 at 21:53