简体   繁体   中英

How do I make the entire text visible or increase the visible area while using RichTextBox in WP8 SDK to develop an app?

How do I make the entire text visible or increase the visible area while using RichTextBox in WP8 SDK to develop an app? Xaml code:

        <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);

edit: Entire 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>

Please help. I am stuck at this for hours and I cant seem to figure out what is the problem.

Here the problem screenshot:

在此处输入图片说明

Remove the ScrollViewer.

The Default RichTextBox Template already has one.

Simply set the VerticalScrollBarVisibility property to the RichTextBox, like so:

<RichTextBox VerticalScrollBarVisibility="Auto">
   <!-- ... -->
</RichTextBox>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM