Paste text nicely into a horizontal glass panel or shell?

I saw several other posts about this, but did not see anything that solves my problem. Basically, I need to have some text (bold and jagged) wrap in Stackpanelor Wrappanelnicely. Here's a visual:

enter image description here

I need a combination of the two TextBlocksthat you see. I have the first bold TextBlockone that contains "Title:", and then on the same line I need the next one TextBlock, which may or may not be completed. If it completes, I need the top line so that it stays on the top line and then wraps up as if it were just one TextBlock. Here's a visualized visual visualization of what I need:

enter image description here

Here is my code that I still have:

<toolkit:WrapPanel Orientation="Horizontal">
   <TextBlock Text="Title: " FontWeight="Bold"/>
   <TextBlock TextWrapping="Wrap" Text="More text goes here " />
</toolkit:WrapPanel>

<toolkit:WrapPanel Orientation="Horizontal">
   <TextBlock Text="Title: " FontWeight="Bold"/>
   <TextBlock TextWrapping="Wrap" Text="More text goes here and I want it to wrap lines and go underneath the title but I can't get it to to do that. :( " />
</toolkit:WrapPanel>

, one TextBlock ( ). , TextBlock.Inlines Run , . Inlines MVVM ( , ).

, , TextBlock , , MVVM.

- , ?

+3
4

RichTextBox .

<RichTextBox>
    <Paragraph>
        <Run FontWeight="Bold">Title:</Run>
        <Run>More text goes here and I want it to wrap lines and go underneath the title but I can't get it to to do that. :(</Run>
    </Paragraph>
</RichTextBox>

Text Run , :

    <RichTextBox>
        <Paragraph>
            <Run FontWeight="Bold"
                 Text="{Binding Header}"></Run>
            <Run Text="{Binding Text}"></Run>
        </Paragraph>
    </RichTextBox>
+3

:

<toolkit:WrapPanel Orientation="Horizontal">
   <TextBlock>       
       <Run FontWeight="Bold" Text="{Binding Header}"></Run>     
        <Run Text="{Binding Text}"></Run>    
    </TextBlock>
</toolkit:WrapPanel>
0

Fix property width as StackPanel. it can help you. The problem is that you are not setting the width property, which it considers automatic width.

<StackPanel Orientation="Horizontal" Width="400">
   <TextBlock Text="Title: " FontWeight="Bold"/>
   <TextBlock TextWrapping="Wrap" Text="More text goes here " />
</StackPanel >

<StackPanel  Orientation="Horizontal" Width="400">
   <TextBlock Text="Title: " FontWeight="Bold"/>
   <TextBlock TextWrapping="Wrap" Text="More text goes here and I want it to wrap lines and go underneath the title but I can't get it to to do that. :( " />
</StackPanel >
0
source

Have you tried using this design?

<TextBlock>
    <TextBlock.Inlines>
        <Bold>
            <Bold.Inlines>
                <Run Text="Title: "/>
            </Bold.Inlines>
        </Bold>
        <Run Text="{Binding Text}"/>
    </TextBlock.Inlines>
</TextBlock>

It works like a charm if a text block should be tied to a single block of text.

0
source

All Articles