2

I'm using a viewbox to scale a textblock. But when the fontsize of the textblock is below a certain fontsize I want to trim the text with... and stop scalling.

How can I achieve this?

<Grid x:Name="UserStatusPanel" Grid.Row="1" Grid.Column="1" VerticalAlignment="Center">
    <Viewbox Name="canMain" 
                MaxWidth="{Binding ActualWidth, ElementName=UserStatusPanel}"
                StretchDirection="DownOnly" 
                HorizontalAlignment="Left">

        <TextBlock x:Name="UserStatusLabel" 
                    TextWrapping="Wrap" 
                    Text="{Binding UserStatus}" 
                    FontFamily="Segoe UI" 
                    FontSize="14" 
                    Foreground="{StaticResource AlmostWhite}"
                    TextTrimming="CharacterEllipsis"/>
    </Viewbox>
</Grid>
Xaruth
  • 4,034
  • 3
  • 19
  • 26
Robby Smet
  • 4,649
  • 8
  • 61
  • 104

1 Answers1

0

The only solution I can think of is taking the text out of the viewbox and binding the font size to the viewbox width or another controller value. If you want an example look over here.

You can implement the converter with your own logics.

Community
  • 1
  • 1
Itzik Gili
  • 324
  • 3
  • 16