我有这个代码:
<ScrollViewer x:Name="textScroller" Grid.Row="2">
<Grid x:Name="ContentPanel" Margin="12,0,12,0" DataContext="{Binding}">
<Image x:Name="ImageUrl" Source="{Binding ImageUrl}" Height="198" Width="150" Margin="10 10 10 10" FlowDirection="RightToLeft" HorizontalAlignment="Left" VerticalAlignment="Top" />
<TextBlock x:Name="Content" Text="{Binding Content}" TextWrapping="Wrap" Style="{StaticResource PhoneTextNormalStyle}" Margin="0,41,24,-41" LineStackingStrategy="BlockLineHeight" MaxWidth="478" />
</Grid>
</ScrollViewer>
这段代码中的图像是该文本块的背景,但我希望该文本环绕图像。有可能吗?我找到了这个类似的问题并且有答案仅使用图像和文本块是不可能的。这样对吗?我真的无法在图像中设置某些属性来设置文本不能出现在图像上?我应该如何更改我的代码?
谢谢
编辑:现在这是我的页面的样子:
我希望文本应该位于图像的右侧和图像的下方。
它是重复的WP7 文字环绕图像 and 图像周围的 Silverlight 文本,尽管这些问题还没有得出公认的答案。 Silverlight 中没有这样的选项来自动将文本环绕图像。您可以使用 WebBrowser 组件或使用多个 TextBlock,方法是在向内存中的 TextBlock 添加单词的同时测量文本的大小,并检查何时停止并切换到另一个 TextBlock。我也建议阅读一篇有关字体指标的文章 -MSDN - UI 前沿:Silverlight 中的字体规格,Charles Petzold.
编辑:硬编码示例:
您可以使用下面的代码以硬编码的方式执行您所要求的操作。也许您可以编写一些代码,使其充当控件 - 通过检测矩形(或图像)旁边的嵌套 TextBlock 的高度来自动分割文本。
<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>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)