From a833cba8df283f8db39358373f387766b253cda4 Mon Sep 17 00:00:00 2001 From: Kalaivannan-Ganesan <93248069+Kalaivannan-Ganesan@users.noreply.github.com> Date: Wed, 5 Aug 2026 19:37:34 +0530 Subject: [PATCH 1/2] Done UG correction from Selection.md to Virtualization.md --- .../Word/Word-Processor/uwp/Selection.md | 239 +++++++++--------- .../Word/Word-Processor/uwp/Shapes.md | 36 +-- .../uwp/Styles-and-Templates.md | 31 ++- .../Word/Word-Processor/uwp/Table.md | 141 ++++++----- .../Word-Processor/uwp/Text-Prediction.md | 27 +- .../Word-Processor/uwp/Text-Wrapping-Style.md | 47 ++-- .../Word/Word-Processor/uwp/Touch.md | 25 +- .../Word/Word-Processor/uwp/Undo-Redo.md | 62 +++-- .../Word/Word-Processor/uwp/Virtualization.md | 12 +- 9 files changed, 367 insertions(+), 253 deletions(-) diff --git a/Document-Processing/Word/Word-Processor/uwp/Selection.md b/Document-Processing/Word/Word-Processor/uwp/Selection.md index 6ab179831c..872a4c922d 100644 --- a/Document-Processing/Word/Word-Processor/uwp/Selection.md +++ b/Document-Processing/Word/Word-Processor/uwp/Selection.md @@ -4,115 +4,95 @@ description: Learn here all about Selection support in Syncfusion UWP RichTextBo platform: document-processing control: SfRichTextBoxAdv documentation: ug -keywords: selection +keywords: selection,text-position,hierarchy-index,multi-selection,selection-ranges,lost-focus-behavior,editing-context --- # Selection in UWP RichTextBox (SfRichTextBoxAdv) -The SfRichTextBoxAdv supports selecting a portion of the document either through UI interactions by using mouse, touch, keyboard or through supported APIs. -The following sample code demonstrates how to retrieve text position from document using paragraph instance and offset value. +[`SfRichTextBoxAdv`](https://help.syncfusion.com/cr/uwp/Syncfusion.UI.Xaml.RichTextBoxAdv.SfRichTextBoxAdv.html) supports selecting a portion of the document either through UI interactions using the mouse, touch, or keyboard, or through the supported APIs. + +## Retrieving a text position + +The following sample code demonstrates how to retrieve a text position from a document using a paragraph instance and an offset value. {% tabs %} {% highlight c# %} // Gets the first section of the document. SectionAdv sectionAdv = richTextBoxAdv.Document.Sections[0]; - -{% endhighlight %} - -{% endtabs %} - -{% tabs %} -{% highlight c# %} // Gets the first block from the section, which is a paragraph. ParagraphAdv paragraphAdv = sectionAdv.Blocks[0] as ParagraphAdv; -// Gets the text position of the specified paragraph at offset 24. -// TextPosition is returned as null, if no such paragraph or offset exists in the document. +// Gets the text position of the specified paragraph at offset 24. +// TextPosition is returned as null if no such paragraph or offset exists in the document. TextPosition startPosition = richTextBoxAdv.Document.GetTextPosition(paragraphAdv, 24); - -{% endhighlight %} - - -{% endtabs %} - -{% tabs %} -{% highlight c# %} -// Gets the third block of a section, which is table. +// Gets the third block of a section, which is a table. TableAdv tableAdv = sectionAdv.Blocks[2] as TableAdv; -// Gets the third block from second row second cell of the table, which is paragraph. -ParagraphAdv paragraphAdv = tableAdv.Rows[1].Cells[1].Blocks[2] as ParagraphAdv; -TextPosition position = richTextBoxAdv.Document.GetTextPosition(paragraphAdv, 12); - +// Gets the third block from the second row, second cell of the table, which is a paragraph. +ParagraphAdv paragraphInTable = tableAdv.Rows[1].Cells[1].Blocks[2] as ParagraphAdv; +TextPosition position = richTextBoxAdv.Document.GetTextPosition(paragraphInTable, 12); {% endhighlight %} - {% endtabs %} -The following sample code demonstrates how to retrieve text position from document using hierarchical index. +The following sample code demonstrates how to retrieve a text position from the document using a hierarchical index. {% tabs %} {% highlight c# %} -/* -The hierarchical index should be given as "section-index;block-index;offset-in-paragraph" -If block in the index is paragraph, then next value is considered as offset and position is retrieved. -For example "0;0;1" gets text position of Paragraph (first block of first section) at the offset=1. -If block in the index is table, then next value is considered as row index and following value as cell index. -The value after cell is again a block index. Then the same process continues. -"table-index;row-index;cell-index;block-index;" -For example "0;2;1;1;0;21" gets text position of Paragraph at first block of second cell of second row of table (at third block of first section) at the offset=21. -If offset value is followed by "C" which stands for comment, then the comment is retrieved which is followed by block index in comment. Then the process of retrieving paragraph from block index continues. -paragraph-index;offset-in-paragraph;C;block-index;offset-in-paragraph -For example "0;3;16;C;2;6", gets text position of Paragraph at third block of comment (present at offset = 16 in paragraph at third block of first section) at the offset=6. -*/ -// Gets the text position from the document based on hierarchical index. +// The hierarchical index is "section-index;block-index;offset-in-paragraph". +// If the block at the index is a paragraph, the next value is treated as the offset. +// For example, "0;0;1" gets the text position of the first block of the first section at offset = 1. +// If the block is a table, the next value is the row index, then the cell index, then a block index. +// "table-index;row-index;cell-index;block-index;" +// For example, "0;2;1;1;0;21" gets the text position of the first block of the second cell of the second row of the third block of the first section at offset = 21. +// If the offset value is followed by "C" (comment), the comment is retrieved; the next value is the block index within the comment. +// "paragraph-index;offset-in-paragraph;C;block-index;offset-in-paragraph" +// For example, "0;3;16;C;2;6" gets the text position of the third block of the comment at offset = 6, where the comment is at offset = 16 in the third block of the first section. +// Retrieves the text position from the document based on a hierarchical index. TextPosition position = richTextBoxAdv.Document.GetTextPosition("0;0;24"); -/* Here text position returned should be first section's first block (which is paragraph) and offset=24. */ +// The returned text position is the first section's first block (which is a paragraph) at offset = 24. {% endhighlight %} {% endtabs %} +## Selecting portions of the document + The following sample code demonstrates how to move selection start and selection end both at a specific text position. + {% tabs %} {% highlight c# %} -// Makes an empty selection at the specific text position. +// Makes an empty (collapsed) selection at the specified text position. richTextBoxAdv.Selection.Select(position, position); - {% endhighlight %} {% endtabs %} -The following sample code demonstrates how to select a portion of document. +### Selecting a range of text + +The following sample code demonstrates how to select a portion of the document. + {% tabs %} {% highlight c# %} -// Retrieves the position of the first paragraph start. +// Retrieves the start position of the first paragraph. TextPosition startPosition = richTextBoxAdv.Document.GetTextPosition("0;0;0"); -// Retrieves the position of the first paragraph at offset=20. +// Retrieves the position of the first paragraph at offset = 20. TextPosition endPosition = richTextBoxAdv.Document.GetTextPosition("0;0;20"); -// Selects the text positions in forward direction. +// Selects the text positions in the forward direction. richTextBoxAdv.Selection.Select(startPosition, endPosition); - -{% endhighlight %} - -{% endtabs %} - -{% tabs %} -{% highlight c# %} -// Selects the text positions in reverse direction. +// Selects the text positions in the reverse direction. richTextBoxAdv.Selection.Select(endPosition, startPosition); - {% endhighlight %} {% endtabs %} -N> You can select a text position within a comment with another text position within the same comment only. It is not possible to select a text position within comment with a text position that exists outside of that comment. +N> You can only select a range where both endpoints lie within the same comment. It is not possible to select a range where one endpoint lies inside a comment and the other lies outside of that comment. -## Multi Selection +## Multi selection -The SfRichTextBoxAdv also supports selecting different portions of the document at a time. The following code example demonstrates how to perform multi selection in SfRichTextBoxAdv. +SfRichTextBoxAdv supports selecting different portions of the document at the same time. The following code example demonstrates how to perform multi-selection in the SfRichTextBoxAdv control. {% tabs %} {% highlight c# %} // Retrieves the position of the first paragraph start. @@ -123,7 +103,7 @@ TextPosition endPosition1 = richTextBoxAdv.Document.GetTextPosition("0;0;20"); TextPosition startPosition2 = richTextBoxAdv.Document.GetTextPosition("0;2;0"); // Retrieves the position of the third paragraph at offset=20. TextPosition endPosition2 = richTextBoxAdv.Document.GetTextPosition("0;2;20"); -// Selects the first paragraph and third paragraph at a time, leaving second paragraph. +// Selects the first and third paragraphs at the same time, leaving the second paragraph unselected. richTextBoxAdv.Selection.SelectionRanges.Add(startPosition1, endPosition1); richTextBoxAdv.Selection.SelectionRanges.Add(startPosition2, endPosition2); @@ -132,13 +112,15 @@ richTextBoxAdv.Selection.SelectionRanges.Add(startPosition2, endPosition2); {% endtabs %} -## Apply Formatting for selection +## Applying formatting to a selection + +SfRichTextBoxAdv supports the following format properties that can be applied to the selected content. -The SfRichTextBoxAdv supports the following format properties that can be applied for selection contents. -Character Format-bold, italic, font size, font family, font color, highlight color, underline, strikethrough, subscript, and superscript. -Paragraph Format-before and after spacing, first line, left and right indenting, text justification, line spacing, and multilevel list. -Selection Format-page size and page margin. -The following sample code demonstrates how to apply subscript format for the selected content. +* **Character format** – Bold, italic, font size, font family, font color, highlight color, underline, strikethrough, subscript, and superscript. +* **Paragraph format** – Before and after spacing, first-line indent, left and right indents, text justification, line spacing, and multilevel list. +* **Section format** – Page size and page margin. + +The following sample code demonstrates how to apply subscript format to the selected content. {% tabs %} {% highlight c# %} // Applies subscript format for the selected text contents. @@ -171,7 +153,7 @@ richTextBoxAdv.Selection.SectionFormat.PageMargin = new Thickness(96, 48, 96, 48 {% endtabs %} -## Binding Selection format properties +## Binding selection format properties The SfRichTextBoxAdv provides support to bind the rich-text format options of selection content. The following code sample demonstrates how to bind the bold format option of SfRichTextBoxAdv. @@ -196,17 +178,17 @@ toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding); The following code sample demonstrates how to bind the bold format option of SfRichTextBoxAdv. {% tabs %} {% highlight xaml %} - + {% endhighlight %} {% highlight c# %} -//Initializes the new binding for toggle text alignment property as left. +// Initializes a new binding for toggling the text alignment. Binding binding = new Binding() { Source = richTextBoxAdv, Path = new PropertyPath("Selection.ParagraphFormat.TextAlignment"), Mode = BindingMode.TwoWay, Converter = new LeftAlignmentToggleConverter() }; -//Binds the IsChecked property to Selection.ParagraphFormat.TextAlignment property of RichTextBoxAdv. +// Binds the IsChecked property to the Selection.ParagraphFormat.TextAlignment property of SfRichTextBoxAdv. toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding); @@ -215,84 +197,109 @@ toggleButton.SetBinding(ToggleButton.IsCheckedProperty, binding); {% endtabs %} -## Keyboard shortcuts to perform selection +## Keyboard shortcuts for navigation and selection The following keyboard shortcuts are supported by SfRichTextBoxAdv for navigation. -
Navigation Shortcut
Description
Right Arrow
Navigates to one position forward.
Left Arrow
Navigates to one position backward.
Down Arrow
Navigates to the same position at next line.
Up Arrow
Navigates to the same position at previous line.
Home
Navigates to start of the current line.
End
Navigates to end of the current line.
CTRL + Home
Navigates to the document start position.
CTRL + End
Navigates to the document end position.
CTRL + Right
Navigates to the next word start position.
CTRL + Left
Navigates to the current word start position.
CTRL + Down
Navigates to the next paragraph start position.
CTRL + Up
Navigates to the current paragraph start position.
- -The following keyboard shortcuts are supported by SfRichTextBoxAdv for selection. -
Selection Shortcut
Description
CTRL + Right Arrow
Extends selection to one position forward.
CTRL + Left Arrow
Extends selection to one position backward.
CTRL + Down Arrow
Extends selection to the same position at next line.
CTRL + Up Arrow
Extends selection to the same position at previous line.
SHIFT + Home
Extends selection to start of the current line.
SHIFT + End
Extends selection to end of the current line.
CTRL + SHIFT + Home
Extends selection to the document start position.
CTRL + SHIFT + End
Extends selection to the document end position.
CTRL + SHIFT + Right
Extends selection to the current word end position.
CTRL + SHIFT + Left
Extends selection to the current word start position.
CTRL + SHIFT + Down
Extends selection to the current paragraph end position.
CTRL + SHIFT + Up
Extends selection to the current paragraph start position.
CTRL + A
Selects the entire document.
- -## How to show blinking cursor and selection highlight even when the control lost focus -The SfRichTextBoxAdv control allows you to show the blinking cursor and selection highlight even when the control doesn't have focus. You can choose any one of the following selection visibility options: +| Navigation shortcut | Description | +| --- | --- | +| Right arrow | Navigates one position forward. | +| Left arrow | Navigates one position backward. | +| Down arrow | Navigates to the same position on the next line. | +| Up arrow | Navigates to the same position on the previous line. | +| Home | Navigates to the start of the current line. | +| End | Navigates to the end of the current line. | +| CTRL + Home | Navigates to the start of the document. | +| CTRL + End | Navigates to the end of the document. | +| CTRL + Right | Navigates to the start of the next word. | +| CTRL + Left | Navigates to the start of the current word. | +| CTRL + Down | Navigates to the start of the next paragraph. | +| CTRL + Up | Navigates to the start of the current paragraph. | -* **None** - Don't display neither caret nor selection highlight when the RichTextBox control doesn't have focus. - -* **ShowCaret** - Displays the caret (blinking cursor) when the RichTextBox control doesn't have focus. - -* **ShowSelection** - Displays the selection highlight when the RichTextBox control doesn't have focus. +The following keyboard shortcuts are supported by SfRichTextBoxAdv for selection. -The following code example demonstrates how to display the selection highlight even when the RichTextBox control doesn't have focus. +| Selection shortcut | Description | +| --- | --- | +| CTRL + Right arrow | Extends selection one position forward. | +| CTRL + Left arrow | Extends selection one position backward. | +| CTRL + Down arrow | Extends selection to the same position on the next line. | +| CTRL + Up arrow | Extends selection to the same position on the previous line. | +| SHIFT + Home | Extends selection to the start of the current line. | +| SHIFT + End | Extends selection to the end of the current line. | +| CTRL + SHIFT + Home | Extends selection to the start of the document. | +| CTRL + SHIFT + End | Extends selection to the end of the document. | +| CTRL + SHIFT + Right | Extends selection to the end of the current word. | +| CTRL + SHIFT + Left | Extends selection to the start of the current word. | +| CTRL + SHIFT + Down | Extends selection to the end of the current paragraph. | +| CTRL + SHIFT + Up | Extends selection to the start of the current paragraph. | +| CTRL + A | Selects the entire document. | + +## Showing the caret and selection when the control is unfocused + +SfRichTextBoxAdv lets you show the blinking cursor and selection highlight even when the control does not have focus. You can choose any of the following [`LostFocusBehavior`](https://help.syncfusion.com/cr/uwp/Syncfusion.UI.Xaml.RichTextBoxAdv.LostFocusBehavior.html) values. + +| Value | Description | +| --- | --- | +| `None` | Do not display either the caret or the selection highlight when the control is unfocused. | +| `ShowCaret` | Display the caret (blinking cursor) when the control is unfocused. | +| `ShowSelection` | Display the selection highlight when the control is unfocused. | + +The following code example demonstrates how to display the selection highlight when the control is unfocused. {% tabs %} {% highlight xaml %} - {% endhighlight %} {% highlight c# %} -// Initializes a new instance of RichTextBoxAdv. +// Initializes a new instance of SfRichTextBoxAdv. SfRichTextBoxAdv richTextBoxAdv = new SfRichTextBoxAdv(); -// Displays the selection highlight when the RichTextBox control doesn't have focus. -richTextBoxAdv. LostFocusBehavior = LostFocusBehavior.ShowSelection; - +// Displays the selection highlight when the control is unfocused. +richTextBoxAdv.LostFocusBehavior = LostFocusBehavior.ShowSelection; {% endhighlight %} - {% endtabs %} -N> This API is supported starting from release version v17.4.0.X. - -## How to determine the editing context type +N> The `LostFocusBehavior` API is supported from Syncfusion UWP RichTextBox v17.4.0.X onwards. -The SfRichTextBoxAdv control allows you to know the editing context type based on the selected content. The following are the editing context types: +## Determining the editing context type -* **Text** - Denotes that the editing context is text +SfRichTextBoxAdv lets you determine the editing context type based on the selected content. The following are the [`EditingContextType`](https://help.syncfusion.com/cr/uwp/Syncfusion.UI.Xaml.RichTextBoxAdv.EditingContextType.html) values. -* **Image** - Denotes that the editing context is image - -* **Table** - Denotes that the editing context is table +| Value | Description | +| --- | --- | +| `Text` | The editing context is a text range. | +| `Image` | The editing context is an image. | +| `Table` | The editing context is a table. | The following code example demonstrates how to determine the editing context type based on the selection. {% tabs %} {% highlight c# %} -// Initializes a new instance of RichTextBoxAdv. +// Initializes a new instance of SfRichTextBoxAdv. SfRichTextBoxAdv richTextBoxAdv = new SfRichTextBoxAdv(); if (richTextBoxAdv.Selection.EditingContext.Type == EditingContextType.Text) - { - } +{ +} {% endhighlight %} - {% endtabs %} -## How to delete the selected content - -The SfRichTextBoxAdv supports deleting the selected portion of the document either through UI command, keyboard or through supported APIs. +## Deleting the selected content + +SfRichTextBoxAdv supports deleting the selected portion of the document either through the UI command, the keyboard, or the supported APIs. + +The following code sample demonstrates how to delete the selected portion of the document using the `DeleteCommand`. -The following code sample demonstrates how to delete the selected portion of the document using the DeleteCommand. {% tabs %} -{% highlight Xaml %} - +{% highlight xaml %} +