FlowDocument Constructeurs

Définition

Initialise une nouvelle instance de la classe FlowDocument.

Surcharges

Nom Description
FlowDocument()

Initialise une nouvelle instance vide de la FlowDocument classe.

FlowDocument(Block)

Initialise une nouvelle instance de la FlowDocument classe, en ajoutant un élément spécifié Block comme contenu initial.

FlowDocument()

Initialise une nouvelle instance vide de la FlowDocument classe.

public:
 FlowDocument();
public FlowDocument();
Public Sub New ()

S’applique à

FlowDocument(Block)

Initialise une nouvelle instance de la FlowDocument classe, en ajoutant un élément spécifié Block comme contenu initial.

public:
 FlowDocument(System::Windows::Documents::Block ^ block);
public FlowDocument(System.Windows.Documents.Block block);
new System.Windows.Documents.FlowDocument : System.Windows.Documents.Block -> System.Windows.Documents.FlowDocument
Public Sub New (block As Block)

Paramètres

block
Block

Objet dérivant de la classe abstraite Block , à ajouter en tant que contenu initial.

Exceptions

block a la valeur null.

Exemples

L’exemple suivant illustre l’utilisation de ce constructeur. Dans ce cas, il FlowDocument contient une structure de bloc d’éléments de flux composée d’une exécution de texte imbriquée dans un paragraphe.

FlowDocument flowDoc = new FlowDocument(new Paragraph(new Run("A bit of text content...")));
Dim flowDocSimple As New FlowDocument(New Paragraph(New Run("A bit of text content...")))

L’exemple suivant construit par programmation une table simple 2 x 2, puis utilise le FlowDocument constructeur pour créer un FlowDocument nouveau conteneur contenant la table. Bien qu’une structure de bloc d’élément de flux un peu plus complexe soit utilisée, l’utilisation du constructeur est la même que dans l’exemple précédent.

// A paragraph with sample text will serve as table content.
Paragraph tableText = new Paragraph(new Run("A bit of text content..."));

Table sampleTable = new Table();

// Create and add a couple of columns.
sampleTable.Columns.Add(new TableColumn());
sampleTable.Columns.Add(new TableColumn());

// Create and add a row group and a couple of rows.
sampleTable.RowGroups.Add(new TableRowGroup());
sampleTable.RowGroups[0].Rows.Add(new TableRow());
sampleTable.RowGroups[0].Rows.Add(new TableRow());

// Create four cells initialized with the sample text paragraph.
sampleTable.RowGroups[0].Rows[0].Cells.Add(new TableCell(tableText));
sampleTable.RowGroups[0].Rows[0].Cells.Add(new TableCell(tableText));
sampleTable.RowGroups[0].Rows[1].Cells.Add(new TableCell(tableText));
sampleTable.RowGroups[0].Rows[1].Cells.Add(new TableCell(tableText));

// Finally, use the FlowDocument constructor to create a new FlowDocument containing 
// the table constructed above.
FlowDocument flowDoc = new FlowDocument(sampleTable);
    ' A paragraph with sample text will serve as table content.
    Dim tableText As New Paragraph(New Run("A bit of text content..."))

    Dim sampleTable As New Table()

    ' Create and add a couple of columns.
    sampleTable.Columns.Add(New TableColumn())
    sampleTable.Columns.Add(New TableColumn())

    ' Create and add a row group and a couple of rows.
    sampleTable.RowGroups.Add(New TableRowGroup())
    sampleTable.RowGroups(0).Rows.Add(New TableRow())
    sampleTable.RowGroups(0).Rows.Add(New TableRow())

    ' Create four cells initialized with the sample text paragraph.
    sampleTable.RowGroups(0).Rows(0).Cells.Add(New TableCell(tableText))
    sampleTable.RowGroups(0).Rows(0).Cells.Add(New TableCell(tableText))
    sampleTable.RowGroups(0).Rows(1).Cells.Add(New TableCell(tableText))
    sampleTable.RowGroups(0).Rows(1).Cells.Add(New TableCell(tableText))

    ' Finally, use the FlowDocument constructor to create a new FlowDocument containing 
    ' the table constructed above.
Dim flowDocTable As New FlowDocument(sampleTable)

Remarques

Types d’entrée valides pour block include, , BlockUIContainerList, Paragraph, et SectionTable.

S’applique à