mirror of
https://github.com/Stone-Red-Code/docs-desktop.git
synced 2026-09-04 00:56:03 +02:00
* Suggestion/warning fixes for US-1889327. * Updated H2s. * Minor content edit. * Review edits. * Minor edits. * Update dotnet-desktop-guide/framework/wpf/advanced/localization-attributes-and-comments.md Co-authored-by: Andy (Steve) De George <[email protected]>
72 lines
4.7 KiB
Markdown
72 lines
4.7 KiB
Markdown
---
|
|
title: "How to: Manipulate Flow Content Elements through the Inlines Property"
|
|
ms.date: "03/30/2017"
|
|
ms.custom: devdivchpfy22
|
|
description: Learn how to manipulate Flow Content Elements through the Inlines property.
|
|
dev_langs:
|
|
- "csharp"
|
|
- "vb"
|
|
helpviewer_keywords:
|
|
- "flow content elements [WPF], manipulating through Inlines property"
|
|
- "documents [WPF], manipulating flow Content elements through Inlines property"
|
|
- "Inlines property [WPF], manipulating flow Content elements"
|
|
- "properties [WPF], Inlines [WPF], manipulating flow Content elements"
|
|
ms.assetid: 510780d2-3da1-4360-8763-7054bda22ea3
|
|
---
|
|
# How to: Manipulate Flow Content Elements through the Inlines Property
|
|
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 <xref:System.Windows.Controls.TextBlock>) through the **Inlines** property. This property is used to add and remove items from <xref:System.Windows.Documents.InlineCollection>. Flow content elements that feature an **Inlines** property include:
|
|
|
|
- <xref:System.Windows.Documents.Bold>
|
|
|
|
- <xref:System.Windows.Documents.Hyperlink>
|
|
|
|
- <xref:System.Windows.Documents.Italic>
|
|
|
|
- <xref:System.Windows.Documents.Paragraph>
|
|
|
|
- <xref:System.Windows.Documents.Span>
|
|
|
|
- <xref:System.Windows.Documents.Underline>
|
|
|
|
These examples happen to use <xref:System.Windows.Documents.Span> as the flow content element, but these techniques are applicable to all elements or controls that host an <xref:System.Windows.Documents.InlineCollection> collection.
|
|
|
|
## Create a new Span object
|
|
The following example creates a new <xref:System.Windows.Documents.Span> object, and then uses the **Add** method to add two text runs as content children of the <xref:System.Windows.Documents.Span>.
|
|
|
|
[!code-csharp[SpanSnippets#_SpanInlinesAdd](~/samples/snippets/csharp/VS_Snippets_Wpf/SpanSnippets/CSharp/Window1.xaml.cs#_spaninlinesadd)]
|
|
[!code-vb[SpanSnippets#_SpanInlinesAdd](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SpanSnippets/visualbasic/window1.xaml.vb#_spaninlinesadd)]
|
|
|
|
## Create a new Run element
|
|
The following example creates a new <xref:System.Windows.Documents.Run> element and inserts it at the beginning of the <xref:System.Windows.Documents.Span>.
|
|
|
|
[!code-csharp[SpanSnippets#_SpanInlinesInsert](~/samples/snippets/csharp/VS_Snippets_Wpf/SpanSnippets/CSharp/Window1.xaml.cs#_spaninlinesinsert)]
|
|
[!code-vb[SpanSnippets#_SpanInlinesInsert](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SpanSnippets/visualbasic/window1.xaml.vb#_spaninlinesinsert)]
|
|
|
|
## Get the top-level Inline elements in the Span
|
|
The following example gets the number of top-level <xref:System.Windows.Documents.Inline> elements contained in the <xref:System.Windows.Documents.Span>.
|
|
|
|
[!code-csharp[SpanSnippets#_SpanInlinesCount](~/samples/snippets/csharp/VS_Snippets_Wpf/SpanSnippets/CSharp/Window1.xaml.cs#_spaninlinescount)]
|
|
[!code-vb[SpanSnippets#_SpanInlinesCount](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SpanSnippets/visualbasic/window1.xaml.vb#_spaninlinescount)]
|
|
|
|
## Delete the last Inline element in the Span
|
|
The following example deletes the last <xref:System.Windows.Documents.Inline> element in the <xref:System.Windows.Documents.Span>.
|
|
|
|
[!code-csharp[SpanSnippets#_SpanInlinesRemoveLast](~/samples/snippets/csharp/VS_Snippets_Wpf/SpanSnippets/CSharp/Window1.xaml.cs#_spaninlinesremovelast)]
|
|
[!code-vb[SpanSnippets#_SpanInlinesRemoveLast](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SpanSnippets/visualbasic/window1.xaml.vb#_spaninlinesremovelast)]
|
|
|
|
## Clear all the Inline element content from the Span
|
|
The following example clears all of the contents (<xref:System.Windows.Documents.Inline> elements) from the <xref:System.Windows.Documents.Span>.
|
|
|
|
[!code-csharp[SpanSnippets#_SpanInlinesClear](~/samples/snippets/csharp/VS_Snippets_Wpf/SpanSnippets/CSharp/Window1.xaml.cs#_spaninlinesclear)]
|
|
[!code-vb[SpanSnippets#_SpanInlinesClear](~/samples/snippets/visualbasic/VS_Snippets_Wpf/SpanSnippets/visualbasic/window1.xaml.vb#_spaninlinesclear)]
|
|
|
|
## See also
|
|
|
|
- <xref:System.Windows.Documents.BlockCollection>
|
|
- <xref:System.Windows.Documents.InlineCollection>
|
|
- <xref:System.Windows.Documents.ListItemCollection>
|
|
- [Flow Document Overview](flow-document-overview.md)
|
|
- [Manipulate a FlowDocument through the Blocks Property](how-to-manipulate-a-flowdocument-through-the-blocks-property.md)
|
|
- [Manipulate a Table's Columns through the Columns Property](how-to-manipulate-table-columns-through-the-columns-property.md)
|
|
- [Manipulate a Table's Row Groups through the RowGroups Property](how-to-manipulate-table-row-groups-through-the-rowgroups-property.md)
|