如上所述,我想垂直放置两个RichTextBlocks。我的目的是手动编写第一个RichTextBlock的段落,我希望第二个RichTextBlock(以编程方式给出的内容)在第一个之后开始,我想要发生这种情况,以便第二个RichTextBlock将垂直溢出到下一栏。
下面的代码片段只是为了让您可以看到我正在使用的对象并且没有任何逻辑含义。
<ScrollViewer
Grid.Column="1"
Grid.Row="1"
Grid.RowSpan="2"
HorizontalScrollMode="Auto"
HorizontalScrollBarVisibility="Auto"
VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Disabled"
Padding="20">
<RichTextBlock>
<Paragraph><Run></Run></Paragraph>
<RichTextBlock />
<common:RichTextColumns>
<common:RichTextColumns.ColumnTemplate>
<DataTemplate>
<RichTextBlockOverflow Margin="80,0,0,0" Width="560">
<RichTextBlockOverflow.RenderTransform>
<TranslateTransform X="-1" Y="4"/>
</RichTextBlockOverflow.RenderTransform>
</RichTextBlockOverflow>
</DataTemplate>
</common:RichTextColumns.ColumnTemplate>
<RichTextBlock
htmlToXaml:Properties.Html="{Binding HtmlText}"
Name="RichTextBlockMy"
Margin="10,0,0,0"
Style="{StaticResource ItemRichTextStyle}"
Width="560"/>
</common:RichTextColumns>
</ScrollViewer>
答案 0 :(得分:0)
我认为这就是你想要的。
XAML
<ScrollViewer
HorizontalScrollMode="Auto"
HorizontalScrollBarVisibility="Auto"
VerticalScrollMode="Disabled"
VerticalScrollBarVisibility="Disabled"
Padding="20">
<StackPanel Orientation="Horizontal">
<RichTextBlock>
<Paragraph>
<Run Text="This is fixed RichTextBlock, after this it's RichTextBlock with RichTextColumns" FontSize="20"/>
<LineBreak />
<Run Text="{Binding FirstRtbText}" />
<LineBreak />
<Run Text="End of fixed RichTextBlock" FontSize="20" />
</Paragraph>
</RichTextBlock>
<common:RichTextColumns>
<common:RichTextColumns.ColumnTemplate>
<DataTemplate>
<RichTextBlockOverflow Margin="80,0,0,0" Width="560">
<RichTextBlockOverflow.RenderTransform>
<TranslateTransform X="-1" Y="4"/>
</RichTextBlockOverflow.RenderTransform>
</RichTextBlockOverflow>
</DataTemplate>
</common:RichTextColumns.ColumnTemplate>
<RichTextBlock
common:Properties.Html="{Binding HtmlText}"
Name="RichTextBlockMy"
Margin="10,0,0,0"
Style="{StaticResource ItemRichTextStyle}"
Width="560"/>
</common:RichTextColumns>
</StackPanel>
</ScrollViewer>
C#
public string HtmlText { get; set; }
public string FirstRtbText { get; set; }
public MainPage()
{
this.InitializeComponent();
FirstRtbText = @"<h1>Header One</h1>
<p>Lorem ipsum <em>emphasised text</em> dolor sit amet, <strong>strong text</strong>
consectetur adipisicing elit, <abbr title="""">abbreviated text</abbr> sed do eiusmod tempor
<acronym title="""">acronym text</acronym> incididunt ut labore et dolore magna aliqua. Ut
<q>quoted text</q> enim ad minim veniam, quis nostrud exercitation <a href=""/"">link text</a>
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute <del>deleted text</del>
<ins>inserted text</ins> irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat <code>code text</code> cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<blockquote>
<p>Blockquote. Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia</p>
</blockquote>";
HtmlText = @"<h1>Header One</h1>
<p>Lorem ipsum <em>emphasised text</em> dolor sit amet, <strong>strong text</strong>
consectetur adipisicing elit, <abbr title="""">abbreviated text</abbr> sed do eiusmod tempor
<acronym title="""">acronym text</acronym> incididunt ut labore et dolore magna aliqua. Ut
<q>quoted text</q> enim ad minim veniam, quis nostrud exercitation <a href=""/"">link text</a>
ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute <del>deleted text</del>
<ins>inserted text</ins> irure dolor in reprehenderit in voluptate velit esse cillum
dolore eu fugiat nulla pariatur. Excepteur sint occaecat <code>code text</code> cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<blockquote>
<p>Blockquote. Velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
cupidatat non proident, sunt in culpa qui officia</p>
</blockquote>
<p><cite><a href=""/"">Cite author with link text</a></cite>, 2008</p>
<h2>Header 2</h2>
<p>Extended paragraph. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<ol>
<li>Ordered list</li>
<li>Item 2 Consectetur adipisicing elit</li>
<li>Item 3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua</li>
<li>Item 4</li>
<li>Item 5</li>
</ol>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<h3>Header 3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.</p>
<ul>
<li>Unordered list</li>
<li>Consectetur adipisicing elit</li>
<li>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua</li>
<li>Item</li>
<li>Item</li>
<li>Item</li>
</ul>
<p>Lorem ipsum dolor sit amet,consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.</p>
<pre><code>pre and code pair{
display:block;
line-height:1.833em;
border-top:0.083em solid #200;
}</code></pre>
<p>Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit
anim id est laborum.</p>
<h4>Header 4</h4>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.</p>
<dl>
<dt>Definition list</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
<dt>Lorem ipsum dolor sit amet</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
<dt>Lorem ipsum dolor sit amet</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
<dt>Lorem ipsum dolor sit amet</dt>
<dd>Consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna
aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.</dd>
</dl>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt
ut labore et dolore magna aliqua.</p>
<table summary=""Table summary"">
<caption>Table Caption</caption>
<thead>
<tr>
<th>Header</th><th>Header</th><th>Header</th>
</tr>
</thead>
<tbody>
<tr>
<td>Content</td><td>1</td><td>a</td>
</tr>
<tr>
<td>Content</td><td>2</td><td>b</td>
</tr>
<tr>
<td>Content</td><td>3</td><td>c</td>
</tr>
<tr>
<td>Content</td><td>4</td><td>d</td>
</tr>
<tr>
<td>Content</td><td>5</td><td>e</td>
</tr>
<tr>
<td>Content</td><td>6</td><td>f</td>
</tr>
</tbody>
</table>
<address>Author text</address>
";
this.DataContext = this;
}