Assembly: System.Windows (in System.Windows.dll)
'Declaration Public Function GetPositionAtOffset ( _ offset As Integer, _ direction As LogicalDirection _ ) As TextPointer
- Type: System.Int32
An offset, in symbols, for which to calculate and return the position. If the offset is negative, the returned TextPointer precedes the current TextPointer; otherwise, it follows.
Any of the following is considered to be a symbol:
An opening or closing tag for the TextElement element.
A UIElement element contained in an InlineUIContainer. Note that a UIElement is always counted as exactly one symbol. Any additional content or elements contained by the UIElement are not counted as symbols.
A 16-bit Unicode character inside of a text Run element.
The following code uses the method to select arbitrary text in a RichTextBox.
Private Sub MyButton2_Click(ByVal sender As Object, ByVal e As RoutedEventArgs) MyButton2.IsTabStop = False 'Create two arbitrary TextPointers to specify the range of content to select. Dim MyTP1 As TextPointer = MyPg.ContentStart.GetPositionAtOffset(2, LogicalDirection.Forward) Dim MyTP2 As TextPointer = MyPg.ContentEnd.GetPositionAtOffset(-1, LogicalDirection.Backward) 'Programmatically change the selection in the RichTextBox MyRTB2.Selection.[Select](MyTP1, MyTP2) Dim s As String = MyRTB2.Selection.Text MyRTB2.Focus() End Sub
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.