我创建了用于显示新闻的控件。每个新的都包含文本和图像。在这里,我找到了 RichTextBox 的示例:
<RichTextBox VerticalAlignment="Top">
<Paragraph
TextAlignment="Left">
<InlineUIContainer>
<InlineUIContainer.Child>
<Rectangle
Width="50"
Height="50"
Fill="Red" />
</InlineUIContainer.Child>
</InlineUIContainer>
<InlineUIContainer>
<Border>
<TextBlock
Padding="0"
Width="370"
Margin="0,0,0,-5"
TextWrapping="Wrap"
Text="First part of text that fits to the right of the image before the other part wraps to">
</TextBlock>
</Border>
</InlineUIContainer>
<Run
Text="the next line. This part of the text is already below the image." />
</Paragraph>
</RichTextBox>
但是有问题:new 包含一个文本块(<p>...</p>
),我不能从示例中动态划分文本为 2 个文本块。我该如何解决我的问题?谢谢你。
UPD:这是我的控件的标记:
<UserControl>
<Grid x:Name="LayoutRoot" Background="{StaticResource PhoneChromeBrush}" Margin="0,0,0,-100">
<TextBlock x:Name="tblNewName" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="460" Height="50" TextAlignment="Center" FontFamily="Mangal"/>
<Grid Height="105" Width="441">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="97*"/>
<ColumnDefinition Width="344*"/>
</Grid.ColumnDefinitions>
<Image x:Name="imgThumbnail" Grid.ColumnSpan="2" HorizontalAlignment="Left" Height="100" VerticalAlignment="Top" Width="100"/>
<TextBlock Grid.Column="1" x:Name="tblNewTeaser" HorizontalAlignment="Left" Margin="10,10,0,0" TextWrapping="Wrap" Text="TextBlock" VerticalAlignment="Top" Width="460" Height="50" TextAlignment="Center" FontFamily="Mangal"/>
</Grid>
</Grid>
</UserControl>
我需要在图像周围的文本块中包装文本。