IDGO-6443 avatar image
0 Votes"
IDGO-6443 asked RichardZhang-MSFT commented

UWP : Get Rect of Character in a Textblock.

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;                    

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, there is currently no way to get the exact position of a character, can you explain why? Maybe there are other ways to achieve your goal.

0 Votes 0 ·

Hello, if you have other questions, please feel free to ask

0 Votes 0 ·

0 Answers