System.Windows.Controls.TextBox.GetRectFromCharacterIndex C# (CSharp) Method

GetRectFromCharacterIndex() private method

private GetRectFromCharacterIndex ( int charIndex ) : Rect
charIndex int
return System.Windows.Rect
		public Rect GetRectFromCharacterIndex (int charIndex)
		{
			EnsureDesignMode ();
			// design-mode is not really supported by Moonlight but some tests requires it to "work"
			return Rect.Empty;
		}

Same methods

TextBox::GetRectFromCharacterIndex ( int charIndex, bool trailingEdge ) : Rect

Usage Example

        //returns [0]=Rect of char at end of first line, [1]=Rect of char at start of second line

        Rect[] FindStartEndOfVisualLineRects(int start, Rect startRect)
        {
            int  next = start, len = tb.Text.Length;
            Rect nextRect, prevRect = startRect;

            while ((next = start + 1) < len)
            {
                nextRect = tb.GetRectFromCharacterIndex(next); //next.GetCharacterRect(LogicalDirection.Forward);
                if (nextRect.Top != startRect.Top)
                {
                    return new Rect[2] {
                               prevRect, nextRect
                    }
                }
                ;

                prevRect = nextRect;
            }
            return(null);
        }
All Usage Examples Of System.Windows.Controls.TextBox::GetRectFromCharacterIndex