1

我有一个 Xaml 文件,其中包含该 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 保存此文档时,它会在List中生成以下额外标签..

  <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 文件时,它会抛出错误“集合属性 'System.Windows.Documents.ListItem'.'SiblingListItems' 为空。” 在兄弟姐妹块..

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

我也尝试使用 XamlWriter.Save 但它对我不起作用,因为我正在使用带有参数构造函数的 Genric 类..

提前致谢..

4

0 回答 0