【发布时间】:2012-04-05 17:49:16
【问题描述】:
我从 MSDN 文档中了解到,您无法使用 XAML 属性导出属于 RichTextBox 的图像。这很好,我可以通过重新选择并手动查看块来解决这个问题。
我的问题是,如果我手动重新构建 XAML 以包含图像,RichTextBox 是否能够从 xaml 加载它。
我已经实现了反射和手动 XAML 导出,它在没有图像的情况下也能完美运行。
它会产生这样的图像:
<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph TextAlignment="Left" FontSize="20" FontFamily="Portable User Interface" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" Foreground="#FF000000" >
<Run Text="Test" FontSize="20" FontFamily="Portable User Interface" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" Foreground="#FF000000" />
</Paragraph>
<Paragraph TextAlignment="Left" FontSize="20" FontFamily="Portable User Interface" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" Foreground="#FF000000" >
<InlineUIContainer>
<Image Source="./desert.jpg" Height="150" Width="200" />
</InlineUIContainer>
<Run Text="" FontSize="20" FontFamily="Portable User Interface" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" Foreground="#FF000000" />
</Paragraph>
</Section>
我通过 XAML 属性反馈到 RTB 并中断! (异常是没有用的,只是一个 IllegalArgmentException 说 'Value'。
如果你只取出 InlineUIContainer 部分就可以了!
我无法确定这是否可能是图像位置错误或 RichTextBox 只是不接受除代码外的图像的问题。
我认为可能从 xaml 指定图像的唯一原因是 MSDN 文档显示它:http://msdn.microsoft.com/en-us/library/ee681613(VS.95).aspx。
有什么想法吗?
塔,
安迪。
【问题讨论】:
-
如果我有时间,我想我可以得到silverlight 的符号并调试到代码中,只是不想花这么多时间在上面! :(
标签: silverlight image xaml richtextbox