Search code examples
wpftexttextblock

Textblock displaying "..." instead of "-" when Width="Auto"


I have a Textblock that shows 3 Dots instead of a Minus when Width is set to Auto. The Font is Arial and the FontSize is 20. The Width during Runtime is 7.

<:TextBlock 
    x:Name="LabelText" 
    MaxHeight="50" 
    TextTrimming="CharacterEllipsis" 
    TextWrapping="Wrap" 
    HorizontalAlignment="Left" 
    VerticalAlignment="Center" 
    Grid.Column="1"
    Margin="5,0,0,0" 
    Style="{StaticResource TextLabelFontStyle}" 
    Width="Auto" />   

Anyone know why i dont see the Minus?


Solution

  • This must be some strange TextBlock behaviour. I changed the HorizontalAlignment="Left" to HorizontalAlignment="Stretch" and added TextAlignment="Left". Now it wokrks properly.