UWP : Get Rect of Character in a Textblock.

Indudhar Gowda 426 Reputation points

Get Rect of Character in a Textblock.

I am able to get Rect of Controls using below Code....But I need Character Rect in a Textblock.

    static Rect GetElementRect(FrameworkElement element)
            GeneralTransform transform = element.TransformToVisual(null);
            Point point = transform.TransformPoint(new Point());
            return new Rect(point, new Size(element.ActualWidth, element.ActualHeight));

Textblock may contain same character Multiple Times.

var ClearButtonClicked= GetElementRect(ClearButton);
                if (ClearButtonClicked.Contains(args.CurrentPoint.Position))
                    Text = String.Empty;                    

Universal Windows Platform (UWP)
{count} votes