文档正文</ed:arc>中的<ed:arc>的FlowDocument解析错误

时间:2014-01-30 23:09:16

标签: c# wpf xaml flowdocument

我有以下代码用于将FlowDocument读入内存但是每当我尝试解析它时,我得到XamlParseException并出现以下错误:

A first chance exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: 'Cannot create unknown type '{http://schemas.microsoft.com/expression/2010/drawing}Arc'.' Line number '6' and line position '5'.

以下是我的FD.xaml文件包含的内容:

FD.xaml

<FlowDocument xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
              ColumnWidth="400" FontSize="14" FontFamily="Georgia" 
              xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing" >
    <Paragraph>
        <Canvas Canvas.Top="100" Canvas.Left="402">
            <ed:Arc ArcThickness="10" Fill="Black" EndAngle="360" Height="7" Width="11" Margin="0,0,0,0"/>
            <ed:Arc ArcThickness="10" Fill="Black" EndAngle="360" Height="7" Width="11" Margin="0,12,0,0"/>
            <ed:Arc ArcThickness="10" Fill="Black" EndAngle="360" Height="7" Width="11" Margin="0,24,0,0"/>         
            <ed:Arc ArcThickness="10" Fill="Black" EndAngle="360" Height="7" Width="11" Margin="368,108,0,0"/>
        </Canvas>
    </Paragraph>
</FlowDocument>

MainWindow.xaml.cs

...
String xamlContent = ReadFileContents("FD.xaml");
FlowDocument doc = XamlReader.Parse(xamlContent) as FlowDocument; // Error occurs right here
...

到目前为止我尝试了什么: 添加了对Microsoft.Expression.Drawing的引用,但我仍然无法使其工作。

1 个答案:

答案 0 :(得分:1)

尝试更换:

xmlns:ed="http://schemas.microsoft.com/expression/2010/drawing"

使用:

xmlns:ed="clr-namespace:Microsoft.Expression.Shapes;assembly=Microsoft.Expression.Drawing"