locked
Flow frame RRS feed

  • Question

  • Hi, I have a content in a blocks. I would like to add this blocks to some container/frame to represent them like bellow.

    By the way, this is application for WinStore (not pure WPF)


    Aleksey


    • Edited by Newfriend Sunday, December 1, 2013 8:19 PM
    • Moved by Jason Dot Wang Monday, December 2, 2013 2:58 AM This thread is about Building Windows Store apps with C# or VB
    Sunday, December 1, 2013 8:18 PM

Answers

  • Hi Aleksey,

    Well, I'm not sure if you read both the link and the code I provided you carefully, you cannot directly insert a UIElement into the RichTextBlock, You should put your UIElement as a Child of InlineUIContainer class and put the container into RichTextBlock.

    In your case, it should be something like:

            <RichTextBlock IsTextSelectionEnabled="False">
                <Paragraph>
                    <InlineUIContainer>
                    <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="5"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                    </InlineUIContainer>
                </Paragraph>
            </RichTextBlock>

    --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.

    • Marked as answer by Newfriend Tuesday, December 3, 2013 1:47 AM
    Tuesday, December 3, 2013 1:22 AM
    Moderator

All replies

  • Hi Newfriend,

      Welcome to MSDN Forum Support.

     

      You are more likely to get more efficient responses to Building Windows Store apps with C# or VB issues at 

      http://social.msdn.microsoft.com/Forums/windowsapps/en-US/home?forum=winappswithcsharp

     where you can contact Building Windows Store apps with C# or VB experts.



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, December 2, 2013 2:57 AM
  • Hi Newfriend,

    You have content in block and wanna add the block to a container?

    Well, basically in Windows Store App, we use RichTextBlock to display blocks, you could use RichTextBlock.Blocks to get the BlockCollection, in where you could use following statement to add an existing block. Or I miss something?

    RichTextBlock.Blocks.Add(yourBlock);

    --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.

    • Marked as answer by Newfriend Monday, December 2, 2013 4:40 AM
    • Unmarked as answer by Newfriend Monday, December 2, 2013 5:05 PM
    Monday, December 2, 2013 3:09 AM
    Moderator
  • Em, but it's not a text actually... I have a kind of buttons. It's cant be up to 10-15 with different length. Should I still use RichTextBlocks even in this case?

    Aleksey

    Monday, December 2, 2013 3:25 AM
  • Of course you can, InlineUIContainer is the one that can accept controls such as button in the RichTextBlock, Take a look at the content model section in RichTextBox Overview.

                InlineUIContainer inline = new InlineUIContainer();
                inline.Child = new Button();
                Paragraph block = new Paragraph();
                block.Inlines.Add(inline);
                rtb.Blocks.Add(block);

    --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, December 2, 2013 3:41 AM
    Moderator
  • So, am I right that nothing else rather than RichTextBox here? I mean, it's a bit confusing to use TextBox as container for the non-text objects...

    Aleksey

    Monday, December 2, 2013 4:15 AM
  • Correct, RichTextBlock is the only thing that can accept block that contain UI controls in windows store app. Block cannot be used directly under a page control.

    Well, the prefix "Rich" might be the answer for why the RichTextBlock can accept non-text object.

    --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, December 2, 2013 4:31 AM
    Moderator
  • I can't add grid with nested elements...

    <RichTextBlock IsTextSelectionEnabled="False">
    <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
    <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition Width="5"/>
    <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    </Grid>
    </RichTextBlock>

    Cause error in markup as well as with paragraph block:

    <RichTextBlock IsTextSelectionEnabled="False">
    <Paragraph>
    <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
    <Grid.ColumnDefinitions>
    <ColumnDefinition/>
    <ColumnDefinition Width="5"/>
    <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    </Grid>
    </Paragraph>
    </RichTextBlock>


    Aleksey

    Monday, December 2, 2013 5:15 PM
  • Hi Aleksey,

    Well, I'm not sure if you read both the link and the code I provided you carefully, you cannot directly insert a UIElement into the RichTextBlock, You should put your UIElement as a Child of InlineUIContainer class and put the container into RichTextBlock.

    In your case, it should be something like:

            <RichTextBlock IsTextSelectionEnabled="False">
                <Paragraph>
                    <InlineUIContainer>
                    <Grid HorizontalAlignment="Left" VerticalAlignment="Top">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition/>
                            <ColumnDefinition Width="5"/>
                            <ColumnDefinition/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                    </InlineUIContainer>
                </Paragraph>
            </RichTextBlock>

    --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.

    • Marked as answer by Newfriend Tuesday, December 3, 2013 1:47 AM
    Tuesday, December 3, 2013 1:22 AM
    Moderator
  • Sorry, I'm not so advanced in programming. Thanks for XAML example. It's works now )

    Aleksey

    Tuesday, December 3, 2013 1:47 AM