Scrolling Richtextblock in ContentDialog

In my UWP application, I have a RichTextBlock inside the ContentDialog, and I set some sample height for each element to check if it works or not.

I'm sure the content inside the RichTextBlock is above height = 100, but I can't scroll up or down!

How can i fix this?

<ContentDialog ...> <ScrollViewer Height="100"> <StackPanel Height="100"> <RichTextBlock x:Name="richBox" Height="100"> <Paragraph> <Bold>Release info:</Bold> <LineBreak/> <Run Text="{x:Bind txt[1]}"/> </Paragraph> <Paragraph> <Bold>A commentary by:</Bold> <Run Text="{x:Bind txt[2]}"/> </Paragraph> <Paragraph> <Bold>details:</Bold> <LineBreak/> <Run Text="{x:Bind txt[3]}"/> </Paragraph> </RichTextBlock> </StackPanel> </ScrollViewer> </ContentDialog> 

Contentdialog cannot scroll

+4
source share
1 answer

Try removing the Height definitions in the StackPanel and RichTextBlock .

 <ContentDialog ...> <ScrollViewer Height="100"> <StackPanel> <RichTextBlock x:Name="richBox"> <Paragraph> <Bold>Release info:</Bold> <LineBreak/> <Run Text="{x:Bind txt[1]}"/> </Paragraph> <Paragraph> <Bold>A commentary by:</Bold> <Run Text="{x:Bind txt[2]}"/> </Paragraph> <Paragraph> <Bold>details:</Bold> <LineBreak/> <Run Text="{x:Bind txt[3]}"/> </Paragraph> </RichTextBlock> </StackPanel> </ScrollViewer> </ContentDialog> 

If the child is the same height as the parent ScrollViewer , then the latter does not need to scroll, so the scroll bar will not be provided. Typically, you do not need to specify a ScrollViewer - when the child is higher than the ScrollViewer , a scroll bar is displayed; otherwise it will not be.

+1
source

All Articles