Compartilhar via


Como: Manipular Elementos de Conteúdo de Fluxo através da Propriedade Inlines

These examples demonstrate some of the more common operations that can be performed on inline flow content elements (and containers of such elements, such as TextBlock) through the Inlines property. This property is used to add and remove items from InlineCollection. Flow content elements that feature an Inlines property include:

These examples happen to use Span as the flow content element, but these techniques are applicable to all elements or controls that host an InlineCollection collection.

Exemplo

The following example creates a new Span object, and then uses the Add method to add two text runs as content children of the Span.

            Dim spanx As New Span()
            spanx.Inlines.Add(New Run("A bit of text content..."))
            spanx.Inlines.Add(New Run("A bit more text content..."))
Span spanx = new Span();
spanx.Inlines.Add(new Run("A bit of text content..."));
spanx.Inlines.Add(new Run("A bit more text content..."));

The following example creates a new Run element and inserts it at the beginning of the Span.

            Dim runx As New Run("Text to insert...")
            spanx.Inlines.InsertBefore(spanx.Inlines.FirstInline, runx)
Run runx = new Run("Text to insert...");
spanx.Inlines.InsertBefore(spanx.Inlines.FirstInline, runx);

The following example gets the number of top-level Inline elements contained in the Span.

            Dim countTopLevelInlines As Integer = spanx.Inlines.Count
int countTopLevelInlines = spanx.Inlines.Count;

The following example deletes the last Inline element in the Span.

            spanx.Inlines.Remove(spanx.Inlines.LastInline)
spanx.Inlines.Remove(spanx.Inlines.LastInline);

The following example clears all of the contents (Inline elements) from the Span.

            spanx.Inlines.Clear()
spanx.Inlines.Clear();

Consulte também

Tarefas

Como: Manipular um FlowDocument por meio da Propriedade Blocks

Como: Manipular as colunas de uma tabela por meio da propriedade Columns

Como: Manipulate a Table's Row Groups through the RowGroups Property

Referência

BlockCollection

InlineCollection

ListItemCollection

Conceitos

Flow Document Overview