' Collection属性' System.Windows.Documents.ListItem'。' SiblingListItems'一片空白。当我使用Xamlservices.Load()加载xaml时

时间:2012-11-28 17:18:45

标签: wpf xaml serialization

我有一个Xaml文件,其中包含Flow文档&在Xaml文件中列出项目。
            这是我的代码,

            xmlns:p="http://schemas.microsoft.com/winfx/2006/xaml/presentation";

            <Book>
              <Ins>
                 <p:FlowDocument>
                    <p:List StartIndex="1">
                        <p:ListItem>
                           <p:Paragraph>Some Text.</p:Paragraph>
                        </p:ListItem>
                        <p:ListItem>
                            <p:Paragraph>Some Text.</p:Paragraph>
                        </p:ListItem>
                    </p:List>
                 </p:FlowDocument>
              </Ins>
            </Book>

     private FlowDocument _notes;
        public FlowDocument Notes
                {            
                    get { return _notes; }
                    set
                    {
                        if (_notes!= value)
                        {
                            _notes= value;
                            RaisePropertyChanged(() => Notes);
                        }
                    }
                }

我可以加载此文档..当我尝试使用XamlServices.Save保存此文档时,它会在列表中生成以下额外标记..

  <av:List.SiblingBlocks>
         <x:Reference>__ReferenceID13</x:Reference>
    </av:List.SiblingBlocks>
  <av:ListItem.SiblingListItems>
       <x:Reference>__ReferenceID9</x:Reference>
              <x:Reference>__ReferenceID12</x:Reference>
</av:ListItem.SiblingListItems>

当我尝试加载这个新保存的Xaml文件时,它会抛出一个错误 “Collection属性'System.Windows.Documents.ListItem'。'SiblingListItems'为空。”在兄弟姐妹区..

我认为我的问题是使用Flow文档,因为它是wpf类型对象我不能使用流文档(Wpf类型对象)与XamlServices.Load()... 我可以为Flow文档(不是wpf类型的对象)提供任何替代方法......

我也尝试过使用XamlWriter.Save,但它对我不起作用,因为我使用Genric类和参数构造函数。

先谢谢..

0 个答案:

没有答案