I want to apply ScaleTransform on a TextBlock while TextWrapping=Wrap.
This is my xaml:
<Grid>
<Border ClipToBounds="True" Background="Beige" Width="200" Height="200">
<TextBlock TextWrapping="Wrap" FontSize="20" Text="AB CD EF GH IG KL MN OP QR ST UV WX YZ">
<TextBlock.RenderTransform>
<ScaleTransform ScaleX="1" />
</TextBlock.RenderTransform>
</TextBlock>
</Border>
</Grid>
It works when ScaleX=1 , but it does not work when ScaleX>1.
Please look at these images :
I need both ScaleTransform and TextWrapping , How can i do it?
You can try LayoutTransform
instead of RenderTransform
. Use the following code snippet to play around:
<Grid>
<DockPanel LastChildFill="True">
<Slider x:Name="Scale" DockPanel.Dock="Bottom" Minimum="1" Maximum="20"/>
<Border ClipToBounds="True" Background="Beige" Width="200" Height="200">
<TextBlock TextWrapping="Wrap" FontSize="20" Text="AB CD EF GH IG KL MN OP QR ST UV WX YZ">
<TextBlock.LayoutTransform>
<ScaleTransform ScaleX="{Binding ElementName=Scale, Path=Value}" ScaleY="{Binding ElementName=Scale, Path=Value}"/>
</TextBlock.LayoutTransform>
</TextBlock>
</Border>
</DockPanel>
</Grid>
P.S. Use slider to adjust scaling and to see how scaling impacting the whole layout
Links: MSDN