在WP8 SDK中使用RichTextBox开发应用程序时,如何使整个文本可见或增加可见区域? Xaml代码:
<RichTextBox x:Name="richText" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" TextWrapping="Wrap">
<Paragraph Name="contentPara">
</Paragraph>
</RichTextBox>
</ScrollViewer>
C#:
Run myRun = new Run();
myRun.Text = App.ViewModel.Items[index].LineThree;
contentPara.Inlines.Add(myRun);
编辑: 整个Xaml:
<phone:PhoneApplicationPage
x:Class="horoscope.hdetail"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot">
<Grid.Background>
<ImageBrush ImageSource="/Assets/background.png" Opacity="0.8" />
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,0">
<TextBlock Text="Bhagawad Gita" Style="{StaticResource PhoneTextNormalStyle}"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0" Height="auto">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<StackPanel Orientation="Horizontal" Grid.Row="0">
<!--<Image x:Name="t2" Width="100" Height="100" Margin="20,0,50,0" />-->
<TextBlock x:Name="t1" Text="Aries" FontSize="60" HorizontalAlignment="Left" Margin="12,0,20,0" />
</StackPanel>
<ScrollViewer Name="scrlvw" Grid.Row="1" Height="auto" Visibility="Visible">
<RichTextBox x:Name="richText" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="0,0,0,0" TextWrapping="Wrap">
<Paragraph Name="contentPara">
</Paragraph>
</RichTextBox>
</ScrollViewer>
</Grid>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" Mode="Minimized">
<shell:ApplicationBarIconButton IconUri="/Assets/questionmark.png" Text="about" Click="ApplicationBarIconButton_Click"/>
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
请帮忙。我被困在这几个小时,我似乎无法弄清楚问题是什么。
这里的问题截图:
答案 0 :(得分:0)
删除ScrollViewer。
Default RichTextBox Template已经有一个。
只需将VerticalScrollBarVisibility
属性设置为RichTextBox,如下所示:
<RichTextBox VerticalScrollBarVisibility="Auto">
<!-- ... -->
</RichTextBox>