How to get a WPF text block for scrolling where the Text property is set asynchronously?

I have a TextBlock wrapped in a ScrollViewer , and the Text TextBlock property is set with the result of the task. TextBlock scrollbars do not adjust the size of the text returned by the task.

Any ideas?

 <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="500"/> </Grid.ColumnDefinitions> <ScrollViewer VerticalScrollBarVisibility="Auto" Height="177" Width="500" HorizontalScrollBarVisibility="Disabled"> <TextBlock Height="177" Text="Extracted Xml" Width="504" HorizontalAlignment="Stretch" TextWrapping="Wrap" /> </ScrollViewer> </Grid> 
+8
c # asynchronous wpf textblock
source share
1 answer

ScrollViewer calculates its scrollbars based on the sizes of the child controls.

So remove the Height property from your TextBlock and ScrollBars should work as expected

+20
source share

All Articles