I have a TextBlock
that can contain long text, so I want to add a vertical scrollbar to it. My initial attempt was to wrap a ScrollViewer
around it. This works, but the problem is that when I zoom in, the width also increases. I tried disabling the horizontal scrollbar as follows:
<ScrollViewer IsTabStop="True" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
But this did not solve the problem. I also tried to snap width:
Width="{Binding ElementName=Scroller, Path=ViewportWidth}"
It didnโt help either.
So my question is: how do I add a vertical scrollbar to it, but have a fixed width and wrapped text for the TextBlock
inside? Here is my full code:
<ScrollViewer Grid.Row="1" IsTabStop="True" VerticalScrollBarVisibility="Auto"> <TextBlock HorizontalAlignment="Center" VerticalAlignment="Top" TextWrapping="Wrap" TextAlignment="Center"/> </ScrollViewer>
source share