How to get rid of whitespace between Runs in TextBlock?
wpf, xaml
Solution
The spaces between the run tags cause the spaces, this is the easiest fix.
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="10"
FontFamily="Arial"
Foreground="#414141">
<Run Text="{Binding LoadsCount}" /><Run Text="+" /><Run Text="{Binding BrokerLoadsCount}" />
</TextBlock>
Because anything between the `<TextBlock>` and `</TextBlock>` is targeting the text property of the TextBlock the whitespace from the breaks between the runs causes the effect you see. You could also shorten it to this.
<Run Text="{Binding LoadsCount}" />+<Run Text="{Binding BrokerLoadsCount}" />
This MSDN article gives all the specifics on how xaml handles the whitespace
http://msdn.microsoft.com/en-us/library/ms788746.aspx
If you were curious why a break and a ton of tabs translates into a single space
All whitespace characters (space, linefeed, tab) are converted into spaces.
All consecutive spaces are deleted and replaced by one space
Problem
I have following XAML: ``` <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="10" FontFamily="Arial" Foreground="#414141"> <Run Text="{Binding LoadsCount}" /> <Run Text="+" /> <Run Text="{Binding BrokerLoadsCount}" /> </TextBlock> ``` And I get display like this: `12 + 11` Somehow it inserts extra space between each `Run` How do I make it display `12+11` ?