我的Xaml
用于我的RichTextBox,它是由WinForms
应用程序生成的。
Xaml
需要使用RichTextBox在Silverlight
中显示,但它不会显示任何内容。
当我使用trycatch并显示错误时,它只显示ArgumentException
并且消息为“value”
<Section xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Paragraph FontSize="16pt"><Run>Windows 8 downloads </Run>
</Paragraph>
<List MarkerStyle="Disc">
<ListItem>
<Paragraph>
<Hyperlink NavigateUri="http://windows.microsoft.com/en-au/windows/buy">Update to Windows 8.1</Hyperlink>
</Paragraph>
</ListItem>
<ListItem>
<Paragraph>
<Hyperlink NavigateUri="http://windows.microsoft.com/en-au/windows/downloads">Free downloads</Hyperlink>
</Paragraph>
</ListItem>
<ListItem>
<Paragraph>
<Hyperlink NavigateUri="http://windows.microsoft.com/en-au/internet-explorer/download-ie">Internet Explorer</Hyperlink>
</Paragraph>
</ListItem>
<ListItem>
<Paragraph>
<Hyperlink NavigateUri="http://www.bing.com/explore/desktop">Desktop wallpaper from Bing</Hyperlink>
</Paragraph>
</ListItem>
</List>
<Paragraph FontSize="16pt">
</Paragraph>
</Section>
C#实施
try
{
rtf.Xaml = xamlRtfCode; //"<Section xml:space="preserve" xm.........";
}
catch(Exception e)
{
MessageBox.Show(e.GetType().ToString() + " - " + e.Message);
}
我将XAML代码更改为下面的代码,现在我有一个不同的错误 (见截图) - 我不知道造成这种情况的原因。
我试过新的Xaml代码
<Section xml:space="preserve" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph><Run FontSize="20" /></Paragraph><Paragraph><Run> </Run></Paragraph><Paragraph><Run FontSize="20" /><Run /><Run /></Paragraph><Paragraph><Span><Run FontFamily="corbel" FontSize="4px"> </Run></Span></Paragraph><Paragraph><Span FontFamily="corbel" FontSize="4px"><Span><Span><Span><Run FontSize="20">Hello world</Run></Span></Span></Span></Span></Paragraph><Paragraph><Run FontFamily="corbel" FontSize="4px" /><Run /><Run /><Run /></Paragraph></Section>
更新
当我从上面的Xaml中删除FontSize属性时,内容在我的RichTextBox中显示正常。所以Xaml代码有些不对。