TextPointerContext Enumeration
.NET Framework 3.0
Determines the category of content that is adjacent to a TextPointer in a specified LogicalDirection.
Namespace: System.Windows.Documents
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
Assembly: PresentationFramework (in presentationframework.dll)
XML Namespace: http://schemas.microsoft.com/winfx/2006/xaml/presentation
| Member name | Description | |
|---|---|---|
| ElementEnd | The TextPointer is adjacent to the closing tag of a TextElement. | |
| ElementStart | The TextPointer is adjacent to the opening tag of a TextElement. | |
| EmbeddedElement | The TextPointer is adjacent to an embedded UIElement or ContentElement. | |
| None | The TextPointer is adjacent to the beginning or end of content. | |
| Text | The TextPointer is adjacent to text. |
// 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.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.Community Additions
ADD
Show: