TextPointerContext TextPointerContext TextPointerContext TextPointerContext Enum

Definición

Determina la categoría de contenido que es adyacente a TextPointer en una LogicalDirection especificada.Determines the category of content that is adjacent to a TextPointer in a specified LogicalDirection.

public enum class TextPointerContext
public enum TextPointerContext
type TextPointerContext = 
Public Enum TextPointerContext
Herencia
TextPointerContextTextPointerContextTextPointerContextTextPointerContext

Campos

ElementEnd ElementEnd ElementEnd ElementEnd 4

TextPointer es adyacente a la etiqueta de cierre de TextElement.The TextPointer is adjacent to the closing tag of a TextElement.

ElementStart ElementStart ElementStart ElementStart 3

TextPointer es adyacente a la etiqueta de apertura de TextElement.The TextPointer is adjacent to the opening tag of a TextElement.

EmbeddedElement EmbeddedElement EmbeddedElement EmbeddedElement 2

TextPointer es adyacente a un UIElement o ContentElement incrustado.The TextPointer is adjacent to an embedded UIElement or ContentElement.

None None None None 0

TextPointer es adyacente al principio o al final del contenido.The TextPointer is adjacent to the beginning or end of content.

Text Text Text Text 1

TextPointer es adyacente al texto.The TextPointer is adjacent to text.

Ejemplos

// This method will extract and return a string that contains a representation of 
// the XAML structure of content elements in a given TextElement.        
string GetXaml(TextElement element)
{
    StringBuilder buffer = new StringBuilder();
 
    // Position a "navigator" pointer before the opening tag of the element.
    TextPointer navigator = element.ElementStart;

    while (navigator.CompareTo(element.ElementEnd) < 0)
    {
        switch (navigator.GetPointerContext(LogicalDirection.Forward))
        {
            case TextPointerContext.ElementStart : 
                // Output opening tag of a TextElement
                buffer.AppendFormat("<{0}>", navigator.GetAdjacentElement(LogicalDirection.Forward).GetType().Name);
                break;
            case TextPointerContext.ElementEnd :
                // Output closing tag of a TextElement
                buffer.AppendFormat("</{0}>", navigator.GetAdjacentElement(LogicalDirection.Forward).GetType().Name);
                break;
            case TextPointerContext.EmbeddedElement :
                // Output simple tag for embedded element
                buffer.AppendFormat("<{0}/>", navigator.GetAdjacentElement(LogicalDirection.Forward).GetType().Name);
                break;
            case TextPointerContext.Text :
                // Output the text content of this text run
                buffer.Append(navigator.GetTextInRun(LogicalDirection.Forward));
                break;
        }
 
        // Advance the naviagtor to the next context position.
        navigator = navigator.GetNextContextPosition(LogicalDirection.Forward);
    
    } // End while.

    return buffer.ToString();

} // End GetXaml method.
' This method will extract and return a string that contains a representation of 
' the XAML structure of content elements in a given TextElement.        
Private Function GetXaml_Renamed(ByVal element As TextElement) As String
    Dim buffer As New StringBuilder()

    ' Position a "navigator" pointer before the opening tag of the element.
    Dim navigator As TextPointer = element.ElementStart

    Do While navigator.CompareTo(element.ElementEnd) < 0
        Select Case navigator.GetPointerContext(LogicalDirection.Forward)
            Case TextPointerContext.ElementStart
                ' Output opening tag of a TextElement
                buffer.AppendFormat("<{0}>", navigator.GetAdjacentElement(LogicalDirection.Forward).GetType().Name)
            Case TextPointerContext.ElementEnd
                ' Output closing tag of a TextElement
                buffer.AppendFormat("</{0}>", navigator.GetAdjacentElement(LogicalDirection.Forward).GetType().Name)
            Case TextPointerContext.EmbeddedElement
                ' Output simple tag for embedded element
                buffer.AppendFormat("<{0}/>", navigator.GetAdjacentElement(LogicalDirection.Forward).GetType().Name)
            Case TextPointerContext.Text
                ' Output the text content of this text run
                buffer.Append(navigator.GetTextInRun(LogicalDirection.Forward))
        End Select

        ' Advance the naviagtor to the next context position.
        navigator = navigator.GetNextContextPosition(LogicalDirection.Forward)

    Loop ' End while.

    Return buffer.ToString()

End Function ' End GetXaml method.

Se aplica a

Consulte también: