RichTextBox does not display all text.

In my Windows Phone application I use richtextbox

    <ScrollViewer Margin="0,0,0,0"  VerticalAlignment="Top">
        <StackPanel Margin="0,0,0,0" Width="Auto"  >
            <RichTextBox x:Name="Browser" Foreground="Black" Height="Auto" cxi:WebBrowserHelper.Html="{Binding BrowserHtml}" Background="Transparent" HorizontalAlignment="Left" VerticalAlignment="Top"  Width="460" Margin="0,0,0,0" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" />
        </StackPanel>
    </ScrollViewer>

But not all text displays. How can I solve this problem?

enter image description hereenter image description here

Update1

After I set height = 700: (see second image)

Update2

    <StackPanel Margin="0,0,0,0" Width="480" Orientation="Vertical">
        <ScrollViewer Margin="0,0,0,0"  VerticalAlignment="Top" Height="1000" >
            <StackPanel Margin="0,0,0,0" Width="Auto"  >
                <RichTextBox x:Name="Browser" Foreground="Black" Height="1000" cxi:WebBrowserHelper.Html="{Binding BrowserHtml}" Background="Transparent" HorizontalAlignment="Left"   Width="460" Margin="0,0,0,0" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" />
            </StackPanel>
        </ScrollViewer>
    </StackPanel>
+3
source share
3 answers

The problem is not RichTextBox, it is caused by using StackPanels. The examples below reproduce the problem / solution using simple rectangles.

The vertically oriented StackPanel expands to the size of the content. This means that the ScrollViewer inside it cannot stretch correctly. For ScrollViewer to work, it must have a fixed size.

This simple example does not work for the same reason:

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <StackPanel Margin="0,0,0,0" Width="480" Orientation="Vertical">
            <ScrollViewer Margin="0,0,0,0"  VerticalAlignment="Stretch">
                  <StackPanel Margin="0,0,0,0" Width="Auto"  >
                       <Rectangle Fill="Aqua" Height="200"/>
                       <Rectangle Fill="Red" Height="200"/>
                       <Rectangle Fill="Yellow" Height="200"/>
                       <Rectangle Fill="Blue" Height="200"/>
                       <Rectangle Fill="Green" Height="200"/>
                  </StackPanel>
             </ScrollViewer>
         </StackPanel>
    </Grid>

( ScrollViewer):

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        <ScrollViewer Margin="0,0,0,0"  VerticalAlignment="Stretch" >
             <StackPanel Margin="0,0,0,0" Width="Auto"  >
                  <Rectangle Fill="Aqua" Height="200"/>
                  <Rectangle Fill="Red" Height="200"/>
                  <Rectangle Fill="Yellow" Height="200"/>
                  <Rectangle Fill="Blue" Height="200"/>
                  <Rectangle Fill="Green" Height="200"/>
             </StackPanel>
         </ScrollViewer>
    </Grid>
+2

height = "auto" RichTextBox. :

 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
            <ScrollViewer Margin="0,0,0,0"  VerticalAlignment="Stretch" >
            <RichTextBox ScrollViewer.VerticalScrollBarVisibility="Visible"  Name="richTextBox" Style="{StaticResource RichTextBoxStyle1}" Height="auto"/>
            </ScrollViewer>
        </Grid>
+1

when using ScrollViewer, u must indicate the height element (fixed or dynamic, as in the grid). otherwise, it occupies the entire height in accordance with the content, even if it goes beyond the screen. so try something like this: "ScrollViewer Height =" 700 ".... '

0
source

All Articles