■ TextElement 클래스를 사용해 텍스트 엘리먼트가 비어있는지 여부를 구하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
using System.Windows.Documents; #region 텍스트 엘리먼트가 비어있는지 여부 구하기 - IsTextElementEmpty(textElement) /// <summary> /// 텍스트 엘리먼트가 비어있는지 여부 구하기 /// </summary> /// <param name="textElement">텍스트 엘리먼트</param> /// <returns>텍스트 엘리먼트가 비어있는지 여부</returns> public bool IsTextElementEmpty(TextElement textElement) { TextPointer startPointer = textElement.ContentStart.GetInsertionPosition(LogicalDirection.Forward); TextPointer endPointer = textElement.ContentEnd.GetInsertionPosition(LogicalDirection.Backward); return startPointer.CompareTo(endPointer) == 0; } #endregion |