Reputation: 2682
In my Windows Phone Application I am using 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 resolve this issue?
Update1
After I put 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>
Upvotes: 3
Views: 2234
Reputation: 11
You must set height="auto" in RichTextBox. The following code works for me:
<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>
Upvotes: 1
Reputation: 93611
The problem is not the RichTextBox, it is caused by your use of StackPanels. Examples below reproduce the problem/solution with simple rectangles.
A vertically oriented StackPanel expands to the size of the content. That means a ScrollViewer inside it cannot stretch correctly to fit. For a ScrollViewer to work it must be a fixed size.
<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>
<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>
Upvotes: 2
Reputation: 6622
when using ScrollViewer u must specify the height element of it (fixed or dynamic as in grid). otherwise it takes all the height as per the content, even if it goes beyond the screen. so try something like this 'ScrollViewer Height="700"....'
Upvotes: 0