Skip to main content

FlowDocument Class

Definition​

Assembly:Avalonia.Controls.Documents
Package:Avalonia.Controls.Documents

Represents a flow document that contains rich text content organized into blocks.

public class FlowDocument

Inheritance: object -> AvaloniaObject -> Animatable -> StyledElement -> FlowDocument

Derived types: Footnote, PageBand

Implements: IChildIndexProvider, IAddChild<Control>, IAddChild<Block>, IAddChild<RichInline>, ck, cn

Constructors​

NameDescription
FlowDocument (2 overloads)Initializes a new instance of the Avalonia.Controls.Documents.FlowDocument class.

FlowDocument overloads​

FlowDocument Constructor​

Initializes a new instance of the Avalonia.Controls.Documents.FlowDocument class.

public FlowDocument()

FlowDocument Constructor​

Initializes a new instance of the Avalonia.Controls.Documents.FlowDocument class with an existing TextDocument.

public FlowDocument(Avalonia.Controls.Documents.TextModel.TextDocument textDocument)
Parameters​

textDocument Avalonia.Controls.Documents.TextModel.TextDocument

The TextDocument to attach to this FlowDocument.

Exceptions​

Methods​

NameDescription
ApplyBlockFormattingApplies captured formatting to an element.
ApplyInlineFormattingApplies captured formatting to an element.
ApplyListItemFormattingApplies captured formatting to an element.
ApplyStylingApplies styling to the control if the control is initialized and styling is not already applied. Inherited from StyledElement.
ApplyTableCellFormattingApplies captured formatting to an element.
ApplyTableRowFormattingApplies captured formatting to an element.
ApplyTextElementFormattingApplies captured formatting to an element.
BeginInitInherited from StyledElement.
Bind (8 overloads)Binds a Avalonia.AvaloniaProperty to an Avalonia.Data.BindingBase. Inherited from AvaloniaObject.
CheckAccessReturns a value indicating whether the current thread is the UI thread. Inherited from AvaloniaObject.
ClearValue (4 overloads)Clears a Avalonia.AvaloniaProperty's local value. Inherited from AvaloniaObject.
CloneCreates a deep, independent copy of this document — content, block/inline structure, formatting and page settings. The source document is left untouched. This is the way to show the same content in several places at once; adding this document's blocks to another document moves them instead, because an element belongs to exactly one document at a time.
CoerceValueCoerces the specified Avalonia.AvaloniaProperty. Inherited from AvaloniaObject.
CreateSnapshotCreates an immutable, thread-safe snapshot of the current document state.
EndInitInherited from StyledElement.
EnsureTextDocumentCreates the backing store if it does not exist yet, and returns it.
EqualsCompares two objects using reference equality. Inherited from AvaloniaObject.
FindFootnoteThe note paired with anchor, or null while the anchor has none (a dangling anchor, or one not in this document). Under the anchor-owns-its-note lifecycle a note exists for every anchor added through the element channel - this is how callers reach it.
FromSnapshotNo summary available.
GetBaseValueInherited from AvaloniaObject.
GetHashCodeGets the hash code for the object. Inherited from AvaloniaObject.
GetValue (3 overloads)Gets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
InitializeTextDocumentCreates the backing store if it does not exist yet, and returns it.
IsAnimatingChecks whether a Avalonia.AvaloniaProperty is animating. Inherited from AvaloniaObject.
IsSetChecks whether a Avalonia.AvaloniaProperty is set on this object. Inherited from AvaloniaObject.
Load (2 overloads)Reads a document from a stream.
LoadAsyncLoads a document from a stream, parsing off the calling thread.
Save (2 overloads)Writes this document to a stream.
SaveAsyncSaves the document to a stream, writing off the calling thread.
SetCurrentValue (2 overloads)Sets the value of a dependency property without changing its value source. Inherited from AvaloniaObject.
SetValue (3 overloads)Sets a Avalonia.AvaloniaProperty value. Inherited from AvaloniaObject.
TryGetResourceInherited from StyledElement.
VerifyAccessChecks that the current thread is the UI thread and throws if not. Inherited from AvaloniaObject.

ApplyBlockFormatting Method​

Applies captured formatting to an element.

public void ApplyBlockFormatting(Avalonia.Controls.Documents.Block block, Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting formatting)

Parameters​

block Avalonia.Controls.Documents.Block

The block to write onto.

formatting Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting

The formatting to apply.

element

The element to write onto.

Remarks​

Resets every property the snapshot tracks, clearing whatever it does not carry. It exists to serve element materialization; to format a live document use Avalonia.Controls.Documents.TextModel.TextRange.ApplyPropertyValue<T>(Avalonia.StyledProperty{<>},<>).

ApplyInlineFormatting Method​

Applies captured formatting to an element.

public void ApplyInlineFormatting(Avalonia.Controls.Documents.RichInline inline, Avalonia.Controls.Documents.TextModel.Formatting.InlineFormatting formatting)

Parameters​

inline Avalonia.Controls.Documents.RichInline

The inline to write onto.

formatting Avalonia.Controls.Documents.TextModel.Formatting.InlineFormatting

The formatting to apply.

element

The element to write onto.

Remarks​

Resets every property the snapshot tracks, clearing whatever it does not carry. It exists to serve element materialization; to format a live document use Avalonia.Controls.Documents.TextModel.TextRange.ApplyPropertyValue<T>(Avalonia.StyledProperty{<>},<>).

ApplyListItemFormatting Method​

Applies captured formatting to an element.

public void ApplyListItemFormatting(Avalonia.Controls.Documents.ListItem item, Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting formatting)

Parameters​

item Avalonia.Controls.Documents.ListItem

The list item to write onto.

formatting Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting

The formatting to apply.

element

The element to write onto.

Remarks​

Resets every property the snapshot tracks, clearing whatever it does not carry. It exists to serve element materialization; to format a live document use Avalonia.Controls.Documents.TextModel.TextRange.ApplyPropertyValue<T>(Avalonia.StyledProperty{<>},<>).

ApplyTableCellFormatting Method​

Applies captured formatting to an element.

public void ApplyTableCellFormatting(Avalonia.Controls.Documents.TableCell cell, Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting formatting)

Parameters​

cell Avalonia.Controls.Documents.TableCell

The cell to write onto.

formatting Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting

The formatting to apply.

element

The element to write onto.

Remarks​

Resets every property the snapshot tracks, clearing whatever it does not carry. It exists to serve element materialization; to format a live document use Avalonia.Controls.Documents.TextModel.TextRange.ApplyPropertyValue<T>(Avalonia.StyledProperty{<>},<>).

ApplyTableRowFormatting Method​

Applies captured formatting to an element.

public void ApplyTableRowFormatting(Avalonia.Controls.Documents.TableRow row, Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting formatting)

Parameters​

row Avalonia.Controls.Documents.TableRow

The row to write onto.

formatting Avalonia.Controls.Documents.TextModel.Formatting.BlockFormatting

The formatting to apply.

element

The element to write onto.

Remarks​

Resets every property the snapshot tracks, clearing whatever it does not carry. It exists to serve element materialization; to format a live document use Avalonia.Controls.Documents.TextModel.TextRange.ApplyPropertyValue<T>(Avalonia.StyledProperty{<>},<>).

ApplyTextElementFormatting Method​

Applies captured formatting to an element.

public void ApplyTextElementFormatting(Avalonia.Controls.Documents.RichTextElement element, Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting formatting)

Parameters​

element Avalonia.Controls.Documents.RichTextElement

The element to write onto.

formatting Avalonia.Controls.Documents.TextModel.Formatting.TextElementFormatting

The formatting to apply.

Remarks​

Resets every property the snapshot tracks, clearing whatever it does not carry. It exists to serve element materialization; to format a live document use Avalonia.Controls.Documents.TextModel.TextRange.ApplyPropertyValue<T>(Avalonia.StyledProperty{<>},<>).

Clone Method​

Creates a deep, independent copy of this document — content, block/inline structure, formatting and page settings. The source document is left untouched. This is the way to show the same content in several places at once; adding this document's blocks to another document moves them instead, because an element belongs to exactly one document at a time.

public Avalonia.Controls.Documents.FlowDocument Clone()

Returns​

Avalonia.Controls.Documents.FlowDocument

A new Avalonia.Controls.Documents.FlowDocument with equivalent content.

CreateSnapshot Method​

Creates an immutable, thread-safe snapshot of the current document state.

public Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot CreateSnapshot()

Returns​

Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot

A Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot that can be serialized from any thread.

Remarks​

The snapshot captures text content (O(1) — references immutable rope nodes), tree structure (O(n) — copies node tree), and formatting (O(n) — value types).

Create a single snapshot and pass it to multiple serializers to avoid redundant tree traversals:

var snapshot = document.CreateSnapshot();
new RtfSerializer().Serialize(snapshot, rtfStream);
new DocxSerializer().Serialize(snapshot, docxStream);

EnsureTextDocument Method​

Creates the backing store if it does not exist yet, and returns it.

public Avalonia.Controls.Documents.TextModel.TextDocument EnsureTextDocument()

Returns​

Avalonia.Controls.Documents.TextModel.TextDocument

The document's Avalonia.Controls.Documents.TextModel.TextDocument.

Remarks​

Read Avalonia.Controls.Documents.FlowDocument.TextDocument instead; it creates the store on first read.

FindFootnote Method​

The note paired with anchor, or null while the anchor has none (a dangling anchor, or one not in this document). Under the anchor-owns-its-note lifecycle a note exists for every anchor added through the element channel - this is how callers reach it.

public Avalonia.Controls.Documents.Footnote FindFootnote(Avalonia.Controls.Documents.RichFootnoteReference anchor)

Parameters​

anchor Avalonia.Controls.Documents.RichFootnoteReference

Returns​

Avalonia.Controls.Documents.Footnote

FromSnapshot Method​

public Avalonia.Controls.Documents.FlowDocument FromSnapshot(Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot snapshot, Action<Avalonia.Controls.Documents.RichTextElement, Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode> formatCallback)

Parameters​

snapshot Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot

formatCallback Action<Avalonia.Controls.Documents.RichTextElement, Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode>

Returns​

Avalonia.Controls.Documents.FlowDocument

InitializeTextDocument Method​

Creates the backing store if it does not exist yet, and returns it.

public Avalonia.Controls.Documents.TextModel.TextDocument InitializeTextDocument()

Returns​

Avalonia.Controls.Documents.TextModel.TextDocument

The document's Avalonia.Controls.Documents.TextModel.TextDocument.

Remarks​

Read Avalonia.Controls.Documents.FlowDocument.TextDocument instead; it creates the store on first read.

Load overloads​

Load Method​

Reads a document from a stream.

public Avalonia.Controls.Documents.FlowDocument Load(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer)
Parameters​

stream System.IO.Stream

The stream to read from.

serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer

The serializer for the format.

Returns​

Avalonia.Controls.Documents.FlowDocument

The document.

Remarks​

The overload taking a System.Threading.CancellationToken is the one to reach for: a large document cannot be abandoned through this one.

Load Method​

Loads a document from a stream on the calling thread.

public Avalonia.Controls.Documents.FlowDocument Load(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer, System.Threading.CancellationToken cancellationToken)
Parameters​

stream System.IO.Stream

The stream to read from.

serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer

The serializer to use.

cancellationToken System.Threading.CancellationToken

Token to cancel the operation.

Returns​

Avalonia.Controls.Documents.FlowDocument

A new Avalonia.Controls.Documents.FlowDocument containing the loaded content.

Remarks​

Parsing and element construction both happen on the calling thread, so a UI-thread caller pays the whole cost on the UI thread. For a large document use Avalonia.Controls.Documents.FlowDocument.LoadAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken), or call this from a background thread and hand the result to the UI - see Avalonia.Controls.Documents.FlowDocument.LoadAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken) for what a background thread may and may not construct.

Exceptions​

LoadAsync Method​

Loads a document from a stream, parsing off the calling thread.

public System.Threading.Tasks.Task<Avalonia.Controls.Documents.FlowDocument> LoadAsync(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer, System.Threading.CancellationToken cancellationToken)

Parameters​

stream System.IO.Stream

The stream to read from.

serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer

The serializer to use.

cancellationToken System.Threading.CancellationToken

Token to cancel the operation.

Returns​

System.Threading.Tasks.Task<Avalonia.Controls.Documents.FlowDocument>

A new Avalonia.Controls.Documents.FlowDocument with the loaded content.

Remarks​

The parse runs on the thread pool; the element tree is then built on the UI thread. A Avalonia.Controls.Documents.FlowDocument and its Avalonia.Controls.Documents.RichTextElements are Avalonia.AvaloniaObjects and bind to the dispatcher of the thread that constructs them, so a document assembled on a pool thread throws on the first property read from the UI thread. The dispatch is explicit rather than left to an ambient System.Threading.SynchronizationContext, which a console host or a caller already off the UI thread does not have.

Await it. Blocking on the returned task from the UI thread deadlocks: the wait occupies the thread the element tree has to be built on. A caller that cannot await uses Avalonia.Controls.Documents.FlowDocument.Load(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken), which parses on the calling thread.

To stay off the UI thread entirely, skip the element facade: read a Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot with the serializer and materialize it with Avalonia.Controls.Documents.TextModel.TextDocument.FromSnapshot(Avalonia.Controls.Documents.Serialization.Snapshot.DocumentSnapshot,Action{Avalonia.Controls.Documents.RichTextElement,Avalonia.Controls.Documents.Serialization.Snapshot.SnapshotNode}). Avalonia.Controls.Documents.FlowDocument.TextDocument carries the whole document and has no thread affinity; Avalonia.Controls.Documents.FlowDocument presents it and is inherently UI-bound.

Exceptions​

Save overloads​

Save Method​

Writes this document to a stream.

public void Save(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer)
Parameters​

stream System.IO.Stream

The stream to write to.

serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer

The serializer for the format.

Remarks​

The overload taking a System.Threading.CancellationToken is the one to reach for: a large document cannot be abandoned through this one.

Save Method​

Saves the document to a stream on the calling thread.

public void Save(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer, System.Threading.CancellationToken cancellationToken)
Parameters​

stream System.IO.Stream

The stream to write to.

serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer

The serializer to use.

cancellationToken System.Threading.CancellationToken

Cancellation token.

Remarks​

Both the snapshot and the write happen on the calling thread, so a UI-thread caller pays the whole cost on the UI thread. For a large document use Avalonia.Controls.Documents.FlowDocument.SaveAsync(System.IO.Stream,Avalonia.Controls.Documents.Serialization.IDocumentSerializer,System.Threading.CancellationToken), which keeps only the snapshot here.

Exceptions​

SaveAsync Method​

Saves the document to a stream, writing off the calling thread.

public System.Threading.Tasks.Task SaveAsync(System.IO.Stream stream, Avalonia.Controls.Documents.Serialization.IDocumentSerializer serializer, System.Threading.CancellationToken cancellationToken)

Parameters​

stream System.IO.Stream

The stream to write to.

serializer Avalonia.Controls.Documents.Serialization.IDocumentSerializer

The serializer to use.

cancellationToken System.Threading.CancellationToken

Cancellation token.

Returns​

System.Threading.Tasks.Task

A task that completes when the save is finished.

Remarks​

This is a thread-offload convenience, not asynchronous I/O: no serializer here performs any, so the write occupies a pool thread for its duration. The snapshot is still captured on the calling thread, because reading the document requires the thread that owns it.

Exceptions​

Properties​

NameDescription
ActualThemeVariantGets the UI theme that is currently used by the element, which might be different than the RequestedThemeVariantProperty. Inherited from StyledElement.
BackgroundGets or sets the document-level background brush.
BlocksGets the top-level blocks that make up this document's content.
ClassesGets or sets the styled element's classes. Inherited from StyledElement.
ContentEndGets a pointer at the end of the document content, or null while no backing store exists.
ContentRangeGets a range covering the whole document, or null while no backing store exists.
ContentStartGets a pointer at the start of the document content, or null while no backing store exists.
DataContextGets or sets the control's data context. Inherited from StyledElement.
DispatcherReturns the Avalonia.AvaloniaObject.Dispatcher that this Avalonia.AvaloniaObject is associated with. Inherited from AvaloniaObject.
FontFamilyGets or sets the document-level font family.
FontSizeGets or sets the document-level font size in device-independent pixels.
FontStretchGets or sets the document-level font stretch.
FontStyleGets or sets the document-level font style.
FontWeightGets or sets the document-level font weight.
FootnoteNumberFormatGets or sets how the document numbers its footnotes: the format of the ordinal each Avalonia.Controls.Documents.RichFootnoteReference renders and its note shows in its number strip. The text document owns the numbering (Avalonia.Controls.Documents.TextModel.TextDocument.FootnoteNumberFormat): a change is one undo unit that re-renders every anchor and note, and a value set before the text document exists applies when it is created. A nested document (a band, a note) ignores it.
FootnotesGets the footnotes this document owns, in anchor order: nested documents like Avalonia.Controls.Documents.FlowDocument.PageBands, each paired by id with the anchor in the body that carries its number. The text document owns them (Avalonia.Controls.Documents.TextModel.TextDocument.Footnotes); they resolve resources and inherited formatting through this element and record undo into the shared undo manager. Notes come and go with their anchors (Avalonia.Controls.Documents.FlowDocument.FindFootnote(Avalonia.Controls.Documents.RichFootnoteReference)); a nested document has none.
ForegroundGets or sets the document-level foreground brush.
IsDocumentInitializedWhether the backing store has been created.
IsInitializedGets a value that indicates whether the element has finished initialization. Inherited from StyledElement.
ItemInherited from AvaloniaObject.
NameGets or sets the name of the styled element. Inherited from StyledElement.
PageBandDistanceGets or sets the distance from the sheet edge to a page band in DIPs: the header's top sits this far below the sheet top, the footer's bottom this far above the sheet bottom. NaN (the default) leaves it to Avalonia.Controls.Documents.PageBandPolicy.DefaultDistance.
PageBandsGets the page bands this document owns: the nested documents its root and top-level sections reference as headers and footers. A band added here - or adopted when an unowned band is set on a reference - belongs to this document: the text document owns it (Avalonia.Controls.Documents.TextModel.TextDocument.PageBands), it resolves resources and inherited formatting through this element and records undo into the shared undo manager. Removing a band clears every reference to it.
PageHeightGets or sets the document page height in DIPs. Set NaN for automatic height from the attached view.
PagePaddingGets or sets the document-level page padding (page margins in document formats). Sections inherit it, like Avalonia.Controls.Documents.FlowDocument.PageWidth and Avalonia.Controls.Documents.FlowDocument.PageHeight, unless they declare their own.
PageWidthGets or sets the document page width in DIPs. Set NaN for automatic width from the attached view.
ParentGets the styled element's logical parent. Inherited from StyledElement.
ResourcesGets or sets the styled element's resource dictionary. Inherited from StyledElement.
RootKindThe kind of the text document's root node: what kind of document this is.
StyleKeyGets the type by which the element is styled. Inherited from StyledElement.
StylesGets the styles for the styled element. Inherited from StyledElement.
TemplatedParentGets the styled element whose lookless template this styled element is part of. Inherited from StyledElement.
TextAlignmentGets or sets the default text alignment for blocks in the document.
TextDocumentGets the Avalonia.Controls.Documents.TextModel.TextDocument backing store, creating it on first read.
ThemeGets or sets the theme to be applied to the element. Inherited from StyledElement.
TransitionsGets or sets the property transitions for the control. Inherited from Animatable.

Background Property​

Gets or sets the document-level background brush.

public Avalonia.Media.IBrush Background { get; set; }

Blocks Property​

Gets the top-level blocks that make up this document's content.

public Avalonia.Controls.Documents.BlockCollection Blocks { get; set; }

ContentEnd Property​

Gets a pointer at the end of the document content, or null while no backing store exists.

public Avalonia.Controls.Documents.TextModel.TextPointer ContentEnd { get; set; }

Remarks​

Returns the backing store's cached pointer instance; see Avalonia.Controls.Documents.FlowDocument.ContentStart for the cloning requirement.

ContentRange Property​

Gets a range covering the whole document, or null while no backing store exists.

public Avalonia.Controls.Documents.TextModel.TextRange ContentRange { get; set; }

Remarks​

Each read allocates a new range, so a mutation through one read does not re-target the range another read returned.

ContentStart Property​

Gets a pointer at the start of the document content, or null while no backing store exists.

public Avalonia.Controls.Documents.TextModel.TextPointer ContentStart { get; set; }

Remarks​

Returns the backing store's cached pointer instance. A caller storing it in a container that later refreshes it calls Avalonia.Controls.Documents.TextModel.TextPointer.Clone first; see Avalonia.Controls.Documents.TextModel.TextDocument.ContentStart.

FontFamily Property​

Gets or sets the document-level font family.

public Avalonia.Media.FontFamily FontFamily { get; set; }

FontSize Property​

Gets or sets the document-level font size in device-independent pixels.

public double FontSize { get; set; }

FontStretch Property​

Gets or sets the document-level font stretch.

public Avalonia.Media.FontStretch FontStretch { get; set; }

FontStyle Property​

Gets or sets the document-level font style.

public Avalonia.Media.FontStyle FontStyle { get; set; }

FontWeight Property​

Gets or sets the document-level font weight.

public Avalonia.Media.FontWeight FontWeight { get; set; }

FootnoteNumberFormat Property​

Gets or sets how the document numbers its footnotes: the format of the ordinal each Avalonia.Controls.Documents.RichFootnoteReference renders and its note shows in its number strip. The text document owns the numbering (Avalonia.Controls.Documents.TextModel.TextDocument.FootnoteNumberFormat): a change is one undo unit that re-renders every anchor and note, and a value set before the text document exists applies when it is created. A nested document (a band, a note) ignores it.

public Avalonia.Controls.Documents.FootnoteNumberFormat FootnoteNumberFormat { get; set; }

Footnotes Property​

Gets the footnotes this document owns, in anchor order: nested documents like Avalonia.Controls.Documents.FlowDocument.PageBands, each paired by id with the anchor in the body that carries its number. The text document owns them (Avalonia.Controls.Documents.TextModel.TextDocument.Footnotes); they resolve resources and inherited formatting through this element and record undo into the shared undo manager. Notes come and go with their anchors (Avalonia.Controls.Documents.FlowDocument.FindFootnote(Avalonia.Controls.Documents.RichFootnoteReference)); a nested document has none.

public Avalonia.Controls.Documents.FootnoteCollection Footnotes { get; set; }

Foreground Property​

Gets or sets the document-level foreground brush.

public Avalonia.Media.IBrush Foreground { get; set; }

IsDocumentInitialized Property​

Whether the backing store has been created.

public bool IsDocumentInitialized { get; set; }

Remarks​

An internal lazy-initialization detail. Reading Avalonia.Controls.Documents.FlowDocument.TextDocument creates the store, so this reports true from the first read onwards and there is nothing a caller can usefully do with it.

PageBandDistance Property​

Gets or sets the distance from the sheet edge to a page band in DIPs: the header's top sits this far below the sheet top, the footer's bottom this far above the sheet bottom. NaN (the default) leaves it to Avalonia.Controls.Documents.PageBandPolicy.DefaultDistance.

public double PageBandDistance { get; set; }

Remarks​

The value belongs to the document, not to a view of it: a band taller than the space it leaves pushes the body down, so screen, print and PDF must all break the document on the same lines. It travels in Avalonia.Controls.Documents.TextModel.Formatting.DocumentFormatting.PageBandDistance.

PageBands Property​

Gets the page bands this document owns: the nested documents its root and top-level sections reference as headers and footers. A band added here - or adopted when an unowned band is set on a reference - belongs to this document: the text document owns it (Avalonia.Controls.Documents.TextModel.TextDocument.PageBands), it resolves resources and inherited formatting through this element and records undo into the shared undo manager. Removing a band clears every reference to it.

public Avalonia.Controls.Documents.PageBandCollection PageBands { get; set; }

PageHeight Property​

Gets or sets the document page height in DIPs. Set NaN for automatic height from the attached view.

public double PageHeight { get; set; }

PagePadding Property​

Gets or sets the document-level page padding (page margins in document formats). Sections inherit it, like Avalonia.Controls.Documents.FlowDocument.PageWidth and Avalonia.Controls.Documents.FlowDocument.PageHeight, unless they declare their own.

public Avalonia.Thickness PagePadding { get; set; }

PageWidth Property​

Gets or sets the document page width in DIPs. Set NaN for automatic width from the attached view.

public double PageWidth { get; set; }

RootKind Property​

The kind of the text document's root node: what kind of document this is.

public Avalonia.Controls.Documents.TextModel.TextDocumentNodeKind RootKind { get; set; }

TextAlignment Property​

Gets or sets the default text alignment for blocks in the document.

public Avalonia.Media.TextAlignment TextAlignment { get; set; }

TextDocument Property​

Gets the Avalonia.Controls.Documents.TextModel.TextDocument backing store, creating it on first read.

public Avalonia.Controls.Documents.TextModel.TextDocument TextDocument { get; set; }

Remarks​

Creation is where the document becomes live: blocks, bands and notes added while no store existed materialize into it, and the change notifications are wired. Reading the property is idempotent but not free the first time, so a caller that only wants to know whether content is already realized reads the element tree instead.

Fields​

NameDescription
BackgroundPropertyDefines the Avalonia.Controls.Documents.FlowDocument.Background property.
DataContextPropertyDefines the Avalonia.StyledElement.DataContext property. Inherited from StyledElement.
FontFamilyPropertyDefines the Avalonia.Controls.Documents.FlowDocument.FontFamily property.
FontSizePropertyDefines the Avalonia.Controls.Documents.FlowDocument.FontSize property.
FontStretchPropertyDefines the Avalonia.Controls.Documents.FlowDocument.FontStretch property.
FontStylePropertyDefines the Avalonia.Controls.Documents.FlowDocument.FontStyle property.
FontWeightPropertyDefines the Avalonia.Controls.Documents.FlowDocument.FontWeight property.
FootnoteNumberFormatPropertyDefines the Avalonia.Controls.Documents.FlowDocument.FootnoteNumberFormat property.
ForegroundPropertyDefines the Avalonia.Controls.Documents.FlowDocument.Foreground property.
NamePropertyDefines the Avalonia.StyledElement.Name property. Inherited from StyledElement.
PageBandDistancePropertyDefines the Avalonia.Controls.Documents.FlowDocument.PageBandDistance property. NaN means the document declares none and the default distance applies.
PageHeightPropertyDefines the Avalonia.Controls.Documents.FlowDocument.PageHeight property. NaN means automatic height from the attached view.
PagePaddingPropertyDefines the Avalonia.Controls.Documents.FlowDocument.PagePadding property.
PageWidthPropertyDefines the Avalonia.Controls.Documents.FlowDocument.PageWidth property. NaN means automatic width from the attached view.
ParentPropertyDefines the Avalonia.StyledElement.Parent property. Inherited from StyledElement.
TemplatedParentPropertyDefines the Avalonia.StyledElement.TemplatedParent property. Inherited from StyledElement.
TextAlignmentPropertyDefines the Avalonia.Controls.Documents.FlowDocument.TextAlignment property.
ThemePropertyDefines the Avalonia.StyledElement.Theme property. Inherited from StyledElement.
TransitionsPropertyDefines the Avalonia.Animation.Animatable.Transitions property. Inherited from Animatable.

BackgroundProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.Background property.

public Avalonia.StyledProperty<Avalonia.Media.IBrush> BackgroundProperty

FontFamilyProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.FontFamily property.

public Avalonia.AttachedProperty<Avalonia.Media.FontFamily> FontFamilyProperty

FontSizeProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.FontSize property.

public Avalonia.AttachedProperty<double> FontSizeProperty

FontStretchProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.FontStretch property.

public Avalonia.AttachedProperty<Avalonia.Media.FontStretch> FontStretchProperty

FontStyleProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.FontStyle property.

public Avalonia.AttachedProperty<Avalonia.Media.FontStyle> FontStyleProperty

FontWeightProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.FontWeight property.

public Avalonia.AttachedProperty<Avalonia.Media.FontWeight> FontWeightProperty

FootnoteNumberFormatProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.FootnoteNumberFormat property.

public Avalonia.StyledProperty<Avalonia.Controls.Documents.FootnoteNumberFormat> FootnoteNumberFormatProperty

ForegroundProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.Foreground property.

public Avalonia.AttachedProperty<Avalonia.Media.IBrush> ForegroundProperty

PageBandDistanceProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.PageBandDistance property. NaN means the document declares none and the default distance applies.

public Avalonia.StyledProperty<double> PageBandDistanceProperty

PageHeightProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.PageHeight property. NaN means automatic height from the attached view.

public Avalonia.StyledProperty<double> PageHeightProperty

PagePaddingProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.PagePadding property.

public Avalonia.StyledProperty<Avalonia.Thickness> PagePaddingProperty

PageWidthProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.PageWidth property. NaN means automatic width from the attached view.

public Avalonia.StyledProperty<double> PageWidthProperty

TextAlignmentProperty Field​

Defines the Avalonia.Controls.Documents.FlowDocument.TextAlignment property.

public Avalonia.AttachedProperty<Avalonia.Media.TextAlignment> TextAlignmentProperty

Events​

NameDescription
ActualThemeVariantChangedRaised when the theme variant is changed on the element or an ancestor of the element. Inherited from StyledElement.
AttachedToLogicalTreeRaised when the styled element is attached to a rooted logical tree. Inherited from StyledElement.
ChildIndexChangedOccurs when the child index of a logical child changes.
DataContextChangedOccurs when the Avalonia.StyledElement.DataContext property changes. Inherited from StyledElement.
DetachedFromLogicalTreeRaised when the styled element is detached from a rooted logical tree. Inherited from StyledElement.
FootnotesChangedRaised when the set of notes changes, a note's id or label changes, or the numbering format changes: the notes a page shows and the numbers they show follow from these, so views re-place them.
InitializedOccurs when the styled element has finished initialization. Inherited from StyledElement.
PageBandsChangedRaised when the set of bands changes or a band's role or rule changes: the pages a band claims by rule follow from these, so views re-resolve their sheets.
PropertyChangedRaised when a Avalonia.AvaloniaProperty value changes on this object. Inherited from AvaloniaObject.
ResourcesChangedOccurs when a resource in this styled element or a parent styled element has changed. Inherited from StyledElement.

ChildIndexChanged Event​

Occurs when the child index of a logical child changes.

public event EventHandler<Avalonia.LogicalTree.ChildIndexChangedEventArgs> ChildIndexChanged

FootnotesChanged Event​

Raised when the set of notes changes, a note's id or label changes, or the numbering format changes: the notes a page shows and the numbers they show follow from these, so views re-place them.

public event EventHandler FootnotesChanged

PageBandsChanged Event​

Raised when the set of bands changes or a band's role or rule changes: the pages a band claims by rule follow from these, so views re-resolve their sheets.

public event EventHandler PageBandsChanged