How to initialize Paragraph Inlines

ⅰ亾dé卋堺 提交于 2019-12-11 10:48:23

问题


How can I initialize paragraph Inline with new InlineCollection? I defined InlineCollection and added Run elements with string to it. I tried to initialize this way

ParagraphComponent.Inlines = _inlineCollection;

However, I get error message that ParagraphComponent.Inline is readonly.


回答1:


From the Remarks section of the Inlines property page on MSDN:

Use the InlineCollection returned by this property to enumerate or manipulate the contents of a Paragraph element.

So you could do this:

ParagraphComponent.Inlines.Clear();
ParagraphComponent.Inlines.AddRange(_inlineCollection);



回答2:


You can't Inlines is read only
You will need to add the Runs directly to the paragraph

In XAML you can define Inlines



来源:https://stackoverflow.com/questions/27888933/how-to-initialize-paragraph-inlines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!