locked
RichTextBlockOverflow. Rich text divide from pages

    Question

  • I want to write FB2 Reader for Windows 8.1 (Store app). Now I wrote a lot of functionality of my application - almost everything, but I stumbled and got stuck on the display of rich text.

    I have content - text, images, headers and i must it divide on pages. Now i using RichTextColumns and scrolling, but this is not what I want.

    I need to break the rich text on the pages, so I could move to definite page and assume always write the header of chapter of a new page.

    I looked a lot of material about the overflow of richtextblock and I still do not understand how I do it. Help please !!! I am very looking for a code example.


    Thursday, September 4, 2014 3:17 PM

Answers

  • So now your question seems to be: How to add text into richtextblock by code.

    Well, RichTextBlock.Blocks.Add() should help you.

                var p = new Paragraph();
                rtb.Blocks.Add(p);

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 10, 2014 10:14 AM
    Moderator

All replies

  • Hi Danil,

    You mean you want to put content to another page in your app? I don't think its possible to binding something cross page in windows store app, you can only pre-define what content should be display in first page and what content in second page.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Friday, September 5, 2014 9:09 AM
    Moderator
  • No, everything is on one page application! I need to create an imitation of book pages by displaying two columns of text on the screen. 

    Okay, you have to manually divide the text, but for this I need to know when a character is beyond the boundaries control richtekstblok.
    Monday, September 8, 2014 6:13 AM
  • Hi Danil,

    If all your controls are in one page, it could be easier, the overflow content from RichTextBlock will be displayed in firstOverflowContainer and the overflow content from firstOverflowContainer will be displayed in secondOverflowContainer.

    <Grid x:Name="columnGrid" Background="White" Width="900" Height="300">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>
                <RichTextBlock Grid.Column="0" IsTextSelectionEnabled="True" TextAlignment="Justify" 
                       OverflowContentTarget="{Binding ElementName=firstOverflowContainer}" 
                       TextIndent="12"
                       FontSize="12" FontFamily="Segoe UI" Foreground="#2a2a2a" Margin="20,0">
                    <Paragraph>
                        <Bold>
                            <Span Foreground="DarkSlateBlue" FontSize="16">Lorem ipsum dolor sit amet</Span>
                        </Bold> , consectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elitconsectetur adipiscing elit. Sed ac mi ipsum. Phasellus vel malesuada mauris. Donec pharetra, enim sit amet mattis tincidunt, felis nisi semper lectus, vel porta diam nisi in augue. Pellentesque lacus tortor, aliquam et faucibus id, rhoncus ut justo. Sed id lectus odio, eget pulvinar diam. Suspendisse eleifend ornare libero, in luctus purus aliquet non. Sed interdum, sem vitae rutrum rhoncus, felis ligula ultrices sem, in eleifend eros ante id neque. Vivamus quam lorem, varius vitae porta mollis, placerat quis est. Aenean eget sagittis massa. Sed tellus turpis, ullamcorper eget imperdiet vel, faucibus vel nisl. Nunc sed suscipit quam. Vivamus convallis faucibus dignissim. Fusce sollicitudin, quam vel cursus mattis, nisl velit tristique sapien, ac vestibulum ante arcu a nisl. Vestibulum commodo gravida ante at tincidunt. Vestibulum in ornare nunc. Nullam ut lorem vitae dui placerat lacinia sit amet a arcu. Nulla sit amet odio nisi. Praesent erat urna, venenatis ac adipiscing vel, congue at lectus. Proin ac metus at quam luctus ultricies.
                    </Paragraph>
                    <Paragraph>
                        <Italic>This is an inline image.</Italic>
                        <InlineUIContainer>
                            <Border Background="Black">
                                <Image Source="Assets/SmallLogo.png" Height="30" Width="30"/>
                            </Border>
                        </InlineUIContainer>
                        Nam vitae ligula non ligula suscipit semper. Duis sed nulla metus, id hendrerit velit. Curabitur dolor purus, bibendum eu cursus lacinia, interdum vel augue. Aenean euismod eros et sapien vehicula dictum. Duis ullamcorper, turpis nec feugiat tincidunt, dui erat luctus risus, aliquam accumsan lacus est vel quam. Nunc lacus massa, varius eget accumsan id, congue sed orci. Duis dignissim hendrerit egestas. Proin ut turpis magna, sit amet porta erat. Nunc semper metus nec magna imperdiet nec vestibulum dui fringilla. Sed sed ante libero, nec porttitor mi. Ut luctus, neque vitae placerat egestas, urna leo auctor magna, sit amet ultricies ipsum felis quis sapien. Proin eleifend varius dui, at vestibulum nunc consectetur nec. Mauris nulla elit, ultrices a sodales non, aliquam ac est. Quisque sit amet risus nulla. Quisque vestibulum posuere velit, vitae vestibulum eros scelerisque sit amet. In in risus est, at laoreet dolor. Nullam aliquet pellentesque convallis. Ut vel tincidunt nulla. Mauris auctor tincidunt auctor.
                    </Paragraph>
                </RichTextBlock>
                <RichTextBlockOverflow x:Name="firstOverflowContainer" Grid.Column="1" Margin="20,0"
                               OverflowContentTarget="{Binding ElementName=secondOverflowContainer}"/>
                <RichTextBlockOverflow x:Name="secondOverflowContainer" Grid.Column="2" Margin="20,0"/>
            </Grid>
    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Monday, September 8, 2014 6:43 AM
    Moderator
  • No, no, no.

    I have a book - many rich text with images. I need to display this text in a FlipView, where each item of flipview represents  two rich text column for users.

    This text must added in some control ( i think - richtextblock) dynamically. How to do it?

    Thanks for you answers

    Tuesday, September 9, 2014 8:36 AM
  • So now your question seems to be: How to add text into richtextblock by code.

    Well, RichTextBlock.Blocks.Add() should help you.

                var p = new Paragraph();
                rtb.Blocks.Add(p);

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    Wednesday, September 10, 2014 10:14 AM
    Moderator