本文整理汇总了C#中System.Windows.Documents.FlowDocument.ClearValue方法的典型用法代码示例。如果您正苦于以下问题:C# FlowDocument.ClearValue方法的具体用法?C# FlowDocument.ClearValue怎么用?C# FlowDocument.ClearValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Documents.FlowDocument
的用法示例。
在下文中一共展示了FlowDocument.ClearValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DocumentChanged
/// <summary>
/// The Document has changed and needs to be updated.
/// </summary>
private void DocumentChanged(FlowDocument oldDocument, FlowDocument newDocument)
{
// Use TextSelection to determine whether the new document belongs to another
// control or not.
if (newDocument != null &&
newDocument.StructuralCache.TextContainer != null &&
newDocument.StructuralCache.TextContainer.TextSelection != null)
{
throw new ArgumentException(SR.Get(SRID.FlowDocumentScrollViewerDocumentBelongsToAnotherFlowDocumentScrollViewerAlready));
}
// Cleanup state associated with the old document.
if (oldDocument != null)
{
// If Document was added to logical tree of FlowDocumentScrollViewer before, remove it.
if (_documentAsLogicalChild)
{
RemoveLogicalChild(oldDocument);
}
// Remove the document from the ContentHost.
if (RenderScope != null)
{
RenderScope.Document = null;
}
oldDocument.ClearValue(PathNode.HiddenParentProperty);
oldDocument.StructuralCache.ClearUpdateInfo(true);
}
// If FlowDocumentScrollViewer was created through style, then do not modify
// the logical tree. Instead, set "core parent" for the Document.
if (newDocument != null && LogicalTreeHelper.GetParent(newDocument) != null)
{
// Set the "core parent" back to us.
ContentOperations.SetParent(newDocument, this);
_documentAsLogicalChild = false;
}
else
{
_documentAsLogicalChild = true;
}
// Initialize state associated with the new document.
if (newDocument != null)
{
// Set the document on the ContentHost.
if (RenderScope != null)
{
RenderScope.Document = newDocument;
}
// If Document should be part of FlowDocumentScrollViewer's logical tree, add it.
if (_documentAsLogicalChild)
{
AddLogicalChild(newDocument);
}
// Set the hidden parent of the document
newDocument.SetValue(PathNode.HiddenParentProperty, this);
newDocument.StructuralCache.ClearUpdateInfo(true);
}
// Attach TextEditor, if content supports it. This method will also
// detach TextEditor from old content.
AttachTextEditor();
// Update the toolbar with our current document state.
if (!CanShowFindToolBar)
{
// Disable FindToolBar, if the content does not support it.
if (FindToolBar != null)
{
ToggleFindToolBar(false);
}
}
// Document is also represented as Automation child. Need to invalidate peer to force update.
FlowDocumentScrollViewerAutomationPeer peer = UIElementAutomationPeer.FromElement(this) as FlowDocumentScrollViewerAutomationPeer;
if (peer != null)
{
peer.InvalidatePeer();
}
}