如何在FlowDocument中隐藏段落? [英] How can I hide a Paragraph in a FlowDocument?
本文介绍了如何在FlowDocument中隐藏段落?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
段落没有Visibility属性。我不知道还有什么要找的。 p>
解决方案
我试过Chris Bova的答案,但有几个问题: / p>
- 文本选择不正确
- 内部的文本不像段
我的解决方案是从流程文档添加和删除段落。
步骤是:
- 命名流文档(即flowDocument) / li>
- 在您要隐藏的段落之前命名项目(即previousBlock)
- 命名要隐藏的段落(即hideParagraph)
然后:
if(< hide段落>)
{
if(previousBlock.NextBlock == hideParagraph)
{
flowDocument.Blocks.Remove(hideParagraph);
}
}
else
{
if(previousBlock.NextBlock!= hideParagraph)
{
flowDocument.Blocks.InsertAfter(previousBlock, hideParagraph);
}
}
Is there any way to use databinding to show or hide a Paragraph within a FlowDocument? (I want to use MVVM, but with a FlowDocument as my view.)
Paragraph doesn't have a Visibility property. I'm not sure what else to look for.
解决方案
I tried Chris Bova's answer, but it had a couple problems:
- Text selection didn't work right
- The text inside didn't flow like a paragraph
My solution was to add and remove the paragraph from the flow document.
The steps are:
- Name the flow document (ie flowDocument)
- Name the item before the paragraph you want to hide (ie previousBlock)
- Name the paragraph you want to hide (ie hideParagraph)
Then:
if (<hide paragraph>)
{
if (previousBlock.NextBlock == hideParagraph)
{
flowDocument.Blocks.Remove(hideParagraph);
}
}
else
{
if (previousBlock.NextBlock != hideParagraph)
{
flowDocument.Blocks.InsertAfter(previousBlock, hideParagraph);
}
}
这篇关于如何在FlowDocument中隐藏段落?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文